leaflet.draw

Leaflet Draw not taking properties when converting FeatureGroup to GeoJson

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 13:54:57
I'm unable to convert my Layer properties into the properties of the GEOJson object using Leaflet(0.7.7)/Leaflet.Draw(latest). My workflow is: 1 Create Map: var map = L.map('#map', options); 2 Create a FeatureGroup: features= new L.FeatureGroup(); 3 Add to the Leaflet Map: map.addLayer(features); 4 On the draw:created event, I'm capturing e.layer and adding a bunch of properties: var layer = e.layer; layer.properties = { Title: 'Hello' }; features.addLayer(layer); geo_features = features.toGeoJSON(); However, my geo_features always have empty property attributes in each of the features and I

update properties of geojson to use it with leaflet

旧城冷巷雨未停 提交于 2019-11-29 08:51:37
I have a requirement of using leaflet.js to add a map to my site. The site has an administration view where an admin can add markers and add description and image to each marker. I used the leaflet.draw plugin, and on the create event I try to update the GeoJSON object I got using event.layer.toGeoJSON() to add some properties like image and text but with no luck. Can any one help me on this? var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors', osm = L.tileLayer(osmUrl, { maxZoom: 18,

How to click a button and start a new polygon without using the Leaflet.draw UI

不想你离开。 提交于 2019-11-29 04:26:04
What I'm struggling with is how to click a button and start a new polygon without using the Leaflet.draw UI. e.g. $('#draw_poly').click(function() { }); I'm able to put an existing polygon into edit mode no problem. $('.edit_polygon').click(function() { var name = $(this).text(); geojson_layer.eachLayer(function (layer) { if (name == layer.feature.properties.name){ layer.editing.enable(); } }); return false; }); Thanks to Jacob Toye for assistance. I've made a little demo. <!DOCTYPE html> <html> <head> <title>Button click</title> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0

Leaflet.draw mapping: How to initiate the draw function without toolbar?

一笑奈何 提交于 2019-11-27 17:42:32
For anyone experienced with leaflet or leaflet.draw plugin: I want to initiate drawing a polygon without using the toolbar from leaflet.draw . I've managed to find the property that allows editing without using the toolbar ( layer.editing.enable(); ) by searching online (it's not in the main documentation). I can't seem to find how to begin drawing a polygon without the toolbar button. Any help would be much appreciated! Thank you :) This simple code works for me: new L.Draw.Polyline(map, drawControl.options.polyline).enable(); Just put it into the onclick handler of your custom button (or