Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to add an id to the Markers. #174

Open
TZAdvantage opened this issue Nov 14, 2018 · 3 comments
Open

Is it possible to add an id to the Markers. #174

TZAdvantage opened this issue Nov 14, 2018 · 3 comments

Comments

@TZAdvantage
Copy link

TZAdvantage commented Nov 14, 2018

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?

@raph-tr
Copy link

raph-tr commented Jun 12, 2020

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
Copy link

raph-tr commented Jun 12, 2020

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

@lkgamor
Copy link

lkgamor commented Oct 30, 2020

You can try this approach too..

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants