bopen / leaflet-area-selection

Create and manipulate a polygonal area on a Leaflet map
https://bopen.github.io/leaflet-area-selection/
MIT License
36 stars 14 forks source link

Set polygon on activate #8

Closed codeindulgence closed 1 year ago

codeindulgence commented 2 years ago

Hi,

I'm looking for a way to pass in a polygon or list of coords when activating draw mode, which the user can continute to move/add/delete.

Thanks for your work!

keul commented 2 years ago

Hi @codeindulgence, seems a nice feature to add. We are not planning additional work on this plugin in the very-near future but I'm happy to review any pull request for this.

codeindulgence commented 2 years ago

Thanks @keul, happy to try and have a stab at it.

From reading the source I can see that the polygon rendering is driven by the as:marker-add event (or maybe as:pointer-add - can you clarify these?).

I'm thinking it'll be something along the lines of setting this.markers to the set of latLngs then firing the as:update-polygon event.

Any advice you can provide would be appreciated!

keul commented 2 years ago

@codeindulgence so, right now it is already possible to do this with the current API, but it's a bit unfriendly:

Points can be added by converting them using a full set of Leaflet conversion methods

An example is here: https://codesandbox.io/s/leaflet-area-selection-external-path-1cwzre?file=/src/index.js

pierre-alain-b commented 1 year ago

If I propose a pull request with an explanation to add on the doc page, would you accept it?

keul commented 1 year ago

@pierre-alain-b Always happy to see documentation improved. A big 👍 for me

pierre-alain-b commented 1 year ago

See #18