PruneCluster icon indicating copy to clipboard operation
PruneCluster copied to clipboard

Initialize marker with dedicated pane (layer)

Open axelerate opened this issue 7 years ago • 1 comments

Without PruneCluster I would specify my marker creation as follows:

                renderable = L.marker([renderableMetadata.coordinate.latitude, renderableMetadata.coordinate.longitude], {
                    icon: new L.Icon.Default({
                        shadowSize: [0, 0],
                    }),
                    pane: extractedLayerId
                });

Note I was able to dictate what pane to add the marker to, but I no longer can provide options when initializing a marker (the markers are being automatically dumped into leaflet-marker-parse). Is there a workaround to this?

axelerate avatar Sep 20 '16 20:09 axelerate

Hello, looking at the changelog the pane attribute is a new feature of Leaflet 1.0.

The main problem I see is the lack of a setPane method in the new API. PruneCluster recycles the markers for performances reasons, so if you plan to have markers on different layers, that will probably not be possible easily.

If you just want to have all markers on the same pane, a quick workaround would be to override BuildLeafletMarker (and maybe BuildLeafletCluster) to something like this:

leafletView.BuildLeafletMarker = function(marker, position) {
    var m = new L.Marker(position, { pane: "paneId" } );
    PruneClusterForLeaflet.prototype.PrepareLeafletMarker.call(this,
        m, marker.data, marker.category);
    return m;
};

I hope it helps.

fungiboletus avatar Sep 21 '16 08:09 fungiboletus