PruneCluster icon indicating copy to clipboard operation
PruneCluster copied to clipboard

Is it possible to add an id to the Markers.

Open TZAdvantage opened this issue 5 years ago • 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?

TZAdvantage avatar Nov 14 '18 22:11 TZAdvantage

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

raph-tr avatar Jun 12 '20 11:06 raph-tr

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...

raph-tr avatar Jun 12 '20 11:06 raph-tr

You can try this approach too..

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

lkgamor avatar Oct 30 '20 10:10 lkgamor