SINTEF-9012/PruneCluster

Is it possible to add an id to the Markers.

TZAdvantage opened this issue · 3 comments

I tried to find how to do it but could not find a solution.

I got my particular use working by adding an id property in the icon options.

    {
         id: vehicle.id
    }

and adding this to the code in ProcessView:

    creationMarker.addTo(map);
    //*** TZAdvantage add id attribute to icon.
    if (creationMarker._icon) {
         creationMarker._icon.id = creationMarker.options.icon.options.id;
    }

Am i overlooking something?

hi,
here is how i do it :

$.each( data, function( key, val ) {
	var marker = new PruneCluster.Marker(
						val.latLng[0],val.latLng[1] ,
						{
							id: key,
							cat: 'site',
							name : val.name
						}
					);
	sitesCluster.RegisterMarker(marker);
});
map.addLayer(sitesCluster);

according to https://github.com/SINTEF-9012/PruneCluster#add-custom-data-to-marker-object
hope it helps

hmm,
by "marker" do you mean the JS marker object (my first thought) or the icon on the map ??
if it is the second choice then my previous answer is not relevant...

You can try this approach too..

const marker = new PruneCluster.Marker(lat, lng, { popup: somePopup, icon: someIcon }); marker.data.id = key;