leaflet-geoman icon indicating copy to clipboard operation
leaflet-geoman copied to clipboard

A way to destroy/un-initialize geoman

Open mike16889 opened this issue 4 years ago β€’ 2 comments

I have found that when destroying the map instance then recreating it, geoman does not get destroyed with it, so when it is re-initialized you get Maximum call stack size exceeded. errors.

Is there a clean way to destroy geoman? or should it get destroyed when the map instance is destroyed.

mike16889 avatar Nov 05 '20 22:11 mike16889

Can you pls share your code with us? A jsfiddle would be nice.

Falke-Design avatar Nov 09 '20 16:11 Falke-Design

This is working without problems:

function initMap(){
  var map = L.map('example2');
  map.on('load move unload',(e)=>console.log(e))
  map.setView([18.74469, 72.1258], 8);
  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    maxZoom: 19,
    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
  }).addTo(map);
  map.pm.addControls();
  return map;
}

var map = initMap();
map.remove();
map = initMap();

Falke-Design avatar Dec 08 '20 09:12 Falke-Design

Closing because of no response

Falke-Design avatar Nov 28 '22 17:11 Falke-Design