-
Notifications
You must be signed in to change notification settings - Fork 993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to programmatically create a marker ? #159
Comments
Yes it's easy. But you don't need Leaflet.draw to do it, just Leaflet. Check the API at http://leafletjs.com/ |
If I do this: |
Hi @delister, you need to make sure the marker is added to the // Normal setup of draw control
var drawnItems = new L.FeatureGroup();
map.addLayer(drawnItems);
// Set the title to show on the polygon button
L.drawLocal.draw.toolbar.buttons.polygon = 'Draw a sexy polygon!';
var drawControl = new L.Control.Draw({
draw: {
position: 'topleft',
polygon: {
allowIntersection: false,
showArea: true,
drawError: {
color: '#b00b00',
timeout: 1000
},
shapeOptions: {
color: '#bada55'
}
},
circle: {
shapeOptions: {
color: '#662d91'
}
},
marker: false
},
edit: {
featureGroup: drawnItems,
remove: false
}
});
map.addControl(drawControl);
// Add marker programatically:
L.marker([51.5, -0.09]).addTo(drawnItems); Note the last line adds the marker to the feature group rather than the map. |
Thanks |
I'm getting this error on edit
P.S. I'm trying to add GeoJSON layer. |
try this code~ L.geoJson(data, {
style: function (feature) {
return {color: feature.properties.color};
},
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.description).addTo(drawnItems);
}
}); |
thanks! |
Tell me is it possible to programmatically create a marker ?
P.S. Translated by google translate.
The text was updated successfully, but these errors were encountered: