geoman-io / leaflet-geoman

🍂🗺️ The most powerful leaflet plugin for drawing and editing geometry layers
https://geoman.io
MIT License
2.21k stars 433 forks source link

Make ability to install PM after map is initialized #823

Closed rendrom closed 3 years ago

rendrom commented 3 years ago

Hello!

I use asynchronous component loading to avoid load extra code if editing is not require. In current version of PM, if the leaflet map has already been initialized, the editor will not work in the usual way of initializing. For myself, I decided in this way:

const pm = new (L.PM as any).Map(map);
map.pm = pm;

it would be great to have PM method to properly set the editor to an already initialized map. For example:

L.PM.addTo(map)

and also be great to import such a method directly from the library

import setup from '@geoman-io/leaflet-geoman-free';

setup(leafltMap);

if such library development is acceptable, I am ready to prepare the PR after discussing

Falke-Design commented 3 years ago

Let us discuss here: #705