0

Im struggling to find any solution to improve performance of leaflet map with a lot of objects on the map.

What I have done;

Rendering everything I can with canvas. My issue is that I have a lot of markers which requires an image icon. This is not rendered by canvas.

I tried using MarkerCluster and making it compatible with leaflet geoman, but I had to give this up.

Which options exist at this point to improve performance that still allow objects to be editable trough leaflet-geoman?

This did look very interesting https://github.com/MazeMap/Leaflet.LayerGroup.Collision But is also not compatible with editing.

Henrik Maaland
  • 210
  • 2
  • 14

2 Answers2

1

To use MarkerClusters take a look here: Leaflet-Geoman MarkerCluster Issue

Another option would be to disable the Geoman Library until you need it. With the OptIn option: Geoman OptIn (But this is currently only in the develop branche, but will be released in 1-2 weeks)

First set optIn to true and when the user clicks on a layer enable Geoman only for this layer:

L.PM.setOptIn(true);

//add click listener for each layer:
layers.on('click',(e)=>{
   var layer = e.target;
   layer.options.pmIgnore = false;
   L.PM.reInitLayer(layer);
}
Falke Design
  • 10,635
  • 3
  • 15
  • 30
0

Also looking for answer, did you tried:

map.pm.setGlobalOptions({
        limitMarkersToCount: 20
        })

This one valid only for newly created objects not for layers in map?

ejovrh2
  • 59
  • 9
  • Im only editing one object at a time, and limitMarkersToCount only prevent more than n vertexes around the mouse. Which is not an issue since im only editing one object. thanks! But note if you have the same issue, and icons are not really important, you can replace all L.Markers with L.circleMarkers you will get no lag! – Henrik Maaland Nov 06 '20 at 13:29