Create a simple method for adding a marker to a map
See original GitHub issueObjective: Currently, it is fairly hard to add a simple marker for a point coordinate to an OL map.
The most simple take on this, I can find goes like:
var layer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat([6.937, 50.926]))})]})});
map.addLayer(layer);
This is obviously quite some things to learn for beginners who just want to try to do a quick “hello world” in openlayers.
The leaflet equivalent for example looks like this:
var marker = L.marker([50.926, 6.937]).addTo(map);
possible solution:
Create a method/function like the marker
function in leaflet to wrap all the complexity, shown in the example above, to make adding a marker to a map more simple.
From experience I can tell, that beginners chose leaflet over openlayers mostly because of the (unnecessary) complexity for basic things like adding a marker to a map in openlayers.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Adding a Map with a Marker | Maps SDK for Android
This tutorial shows you how to add a Google map to your Android app. The map includes a marker, also called a pin,...
Read more >6 Ways to Add a Marker in Google Maps - wikiHow
1. Open Google Maps. Tap the Google Maps app icon, which resembles a red location marker on a road map. This will open...
Read more >How to Add Custom Marker to Google Maps in Android?
For adding a custom marker to Google Maps navigate to the app > res > drawable > Right-Click on it > New >...
Read more >Adding a Map with a marker on Android - YouTube
Have you ever wanted to add a marker or a pin to your Map to point out a specific location? Developer Relations Engineer...
Read more >How to add Markers on maps [Google Maps Course #2]
We will learn about markers in #Google # Maps . Now, let's move on how to create markers on google maps and customise...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think it would be useful in real world situations as developers would need to style markers to suit their applications (as in this example https://openlayers.org/en/master/examples/icon-color.html). A downside of greater flexibility is it needs slightly more code, but anyone attempting to use any mapping library should know enough javascript to put code they use repeatedly into a function. Maybe the example should be revised to reflect that? https://codepen.io/mike-000/pen/QeJZKX
Have you looked at ol-ext? http://viglino.github.io/ol-ext/