leaflet.draw

leaflet.draw trash button delete all polygons and save

好久不见. 提交于 2019-12-23 09:40:24
问题 Using javascript, how can I alter the leaflet.draw "Trash" button to delete all polygons that have been drawn and automatically save. Below is the code I've implemented but it is a complete hack. It removes the active polygon, but after I delete an object once I begin to get errors in the console when I click the "Trash" icon like NotFoundError: Node was not found and TypeError: this._deletedLayers is null map.on('draw:editstart', function (e) { if(e.handler == 'remove' && typeof drawnItem !=

how to use an R script from github?

主宰稳场 提交于 2019-12-22 05:19:31
问题 I try to use sources creates from github plugin-draw.R how use this blugin? 回答1: You can use solution offered on R-Bloggers: source_github <- function(u) { # load package require(RCurl) # read script lines from website script <- getURL(u, ssl.verifypeer = FALSE) # parase lines and evaluate in the global environment eval(parse(text = script)) } source("https://raw.github.com/tonybreyal/Blog-Reference-Functions/master/R/bingSearchXScraper/bingSearchXScraper.R") For the function to be evaluated

Django RF: POST geometry from Leaflet Draw to PostGIS

走远了吗. 提交于 2019-12-21 22:00:40
问题 I'm trying to store some geometry in a PostGIS DB which is created using Leaflet Draw. The following answer only covers the first part: how to transform the drawn shape into GeoJSON, i.e.: map.on(L.Draw.Event.CREATED, function (e) { var type = e.layerType var layer = e.layer; // Do whatever else you need to. (save to db, add to map etc) drawnItems.addLayer(layer); //Export to DB (source: https://stackoverflow.com/a/24019108/3976696) var shape = layer.toGeoJSON() shape_for_db = JSON.stringify

Leaflet Draw not taking properties when converting FeatureGroup to GeoJson

末鹿安然 提交于 2019-12-18 08:11:03
问题 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

update properties of geojson to use it with leaflet

杀马特。学长 韩版系。学妹 提交于 2019-12-18 05:25:06
问题 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:/

Leaflet Draw “Cannot read property 'enable' of undefined” adding control to geoJSON layer

蓝咒 提交于 2019-12-17 17:04:50
问题 I am trying to use leaflet's edit function on polygons that I loaded from my database. When I click on leaflet's edit button I get the error Cannot read property 'enable' of undefined This thread describes a similar problem, and user ddproxy said "Since FeatureGroup extends LayerGroup You can walk through the layers presented and add them individually to the FeatureGroup used for Leaflet.draw" I am confused what he means by "walk through", I thought I was adding a layer group, so i'm not sure

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

◇◆丶佛笑我妖孽 提交于 2019-12-17 15:34:11
问题 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 :) 回答1: This simple code works for me: new L.Draw.Polyline(map

How do I get a Leaflet shape's layer type when clicking on it?

拈花ヽ惹草 提交于 2019-12-13 03:26:01
问题 My Leaflet project allows the users to draw shapes (lines, rectangles and polygons). The user can click on the shapes to get their statistics (area, perimeter, etc). I tried a click event on my FeatureGroup(), where all the shapes I have drawn is added. I am not sure if this is the best approach. Then upon click, a function taking an event is called. The layer type is inferred from the event object. //Handlers for when drawn shapes are clicked editableLayers.on('click', onLayerClick);

Display Polyline length in feet using Leaflet.Draw toolbar

…衆ロ難τιáo~ 提交于 2019-12-12 12:57:58
问题 I am creating a map that the user will be able to draw lines on using the Leaflet.Draw toolbar. I would like the running distance of the line to be displayed in feet/miles instead of the default yards/miles. Looking at the project in GitHub, it seems to me the following code should do this: var drawControl = new L.Control.Draw({ draw: { polyline: { shapeOptions: { color: 'red', }, metric: false, feet: true, } } }); But the length is still displayed in yards. Any insight into why this is would

How to import a module that extends another on the same namespace

孤者浪人 提交于 2019-12-11 02:25:19
问题 A simple road block. I need to use Leaflet and the Leaflet-Draw plugin in some of my services. I don't know how to import the complete module (core and plugin) // the core import * as L from 'leaflet'; // extension import 'leaflet-draw'; export class LeafletConsumerService {} I have a solution that I don't like much. I load the libraries by hard-linking them in index.html and the consumer simply has a reference declaration to the typings files /// <reference path="../typings/index.d.ts" />