leaflet-geoman
leaflet-geoman copied to clipboard
Opt-In and Text Layer
I'm following the Opt-In documentation: https://github.com/geoman-io/leaflet-geoman#opt-in. Everything works as expected except for Text Layers that don't get properly initialized as shown in the example below.
Demo: https://jsfiddle.net/14pgryc3/4/
My workaround is to manually recreate the marker.
if (event.shape === "Text") {
const marker = event.marker;
if (marker && marker.getLatLng()) {
marker.removeFrom(map);
event.layer = L.marker(marker.getLatLng(), {
textMarker: true,
text: event.text,
pmIgnore: false,
}).addTo(map);
}
}