Questions tagged [leaflet.draw]

Vector drawing and editing plugin for Leaflet

306 questions
47
votes
4 answers

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

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();)…
Sam
  • 900
  • 3
  • 10
  • 16
23
votes
4 answers

Coordinates of Leaflet.Draw rectangle

Is it possible to get the coordinates of the rectangle on mouseClick, so I have all the corners of the rectangle?
mortenstarck
  • 2,713
  • 8
  • 43
  • 76
20
votes
5 answers

TypeError: L.Control.Draw is not a constructor

I wanted to draw a polygon in the leaflet map in my ionic2 app, for that I found leaflet-draw pluggin, but I am getting this error TypeError: L.Control.Draw is not a constructor My code looks this this.map = L .map("map") .setView(this.latLng,…
Nishant
  • 407
  • 2
  • 4
  • 12
11
votes
3 answers

How can I grab a selection of markers with Leaflet.draw?

Context: I've made a map, and populated it with around 300 random markers. I can 'select' the markers by clicking on a link in the popup and activate a selection to display data from. I also have the Leaflet.draw plugin to draw shapes like circles,…
roberrrt-s
  • 7,914
  • 2
  • 46
  • 57
10
votes
1 answer

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

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…
Ground Hog
  • 193
  • 1
  • 3
  • 13
9
votes
1 answer

React leaflet draw - marker icon and drag handler is missing

I am using react leaflet draw for drawing polygons and circles. But when I chose edit polygon there is no drag handler for a move and resize. How to solve this issue if any one have the same? This is code
Stevan Tosic
  • 6,561
  • 10
  • 55
  • 110
8
votes
2 answers

leaflet-draw delete button remove "clear all" action

How can I remove the "clear all" action from the delete button in the leaflet-draw edit toolbar? I know you can remove the whole delete button but still need to remove individual items. Basically looking for a way to prevent the user from deleting…
Jonathan
  • 623
  • 10
  • 17
8
votes
4 answers

Property 'Draw' does not exist on type 'typeof Control'

I'm attempting to implement a map component with leaflet and other leaflet plugins. The issue is other plugins don't work from TypeScript for some reason. For example I'm unable to compile code with leaflet-draw plugin and getting the…
aclowkay
  • 3,577
  • 5
  • 35
  • 66
7
votes
1 answer

Add existing leaflet polygons to an existing leaflet layer

I have a bunch of polygons which are stored in a database. I would like to add them to the map in such a way that they can be edited using the leaflet-draw toolbar. Although, now the polygons get added to the map, I am unable edit them. I think this…
codejunkie
  • 908
  • 2
  • 21
  • 34
7
votes
2 answers

Leaflet-Draw: Get polygon latLng in 'draw:editvertex' event

When a draw:editvertex event fires, how can I get information about the polygon which triggered it? this.map.on('draw:editvertex', function (e) { debugger; var layers = e.layers; // I want to get current polygon latLng here }.bind(this));
Kalashir
  • 1,099
  • 4
  • 15
  • 38
7
votes
3 answers

leaflet.draw trash button delete all polygons and save

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…
jduhls
  • 693
  • 7
  • 11
6
votes
2 answers

React-Leaflet-Draw: accessing a polygon's array of coordinates on save

I've got a component which puts an editable polygon on the map. When the user hits the "save" button, I want to access an array of the polygon's new vertices, so that I can save them. How do I do this? My component:
Boris K
  • 3,442
  • 9
  • 48
  • 87
6
votes
1 answer

Disable Leaflet draw toolbar when user creates a shape and enable it when the shape is deleted

I would like to prevent a user from creating more than one shape on the map. For example if the user creates a polygon, then all shape icons on the toolbar should be disabled. When the user deletes the previously created shape, then icons on the…
codejunkie
  • 908
  • 2
  • 21
  • 34
6
votes
3 answers

Leaflet Draw not taking properties when converting FeatureGroup to GeoJson

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…
Chronix3
  • 601
  • 2
  • 9
  • 21
6
votes
1 answer

leaflet.draw does not cancel properly

In the code snippet below, I have setup the leaflet.draw plugin. Works fine for adding features (lines, markers, polygons). Works fine for editing and deleting. But the cancel operation does not work (nor does the simple intersection test, but I can…
Dr.YSG
  • 7,171
  • 22
  • 81
  • 139
1
2 3
20 21