question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ability to add/retrieve data from layer/popup

See original GitHub issue

I’m not sure how to be able to append data to a layer (or even a popup), e.g. adding a custom ID to it, however I cannot append any data to a layer because I don’t know how to get the raw DOM element so I can use it with jQuery by doing so:

$.data(markerLayer, 'test', { id: '123' });

It would be nice to have an ability to be able to append data to a layer and able to retrieve it via events such as click, drag, etc.

Anyone is free to point me to the right direction to how to do this - on one note, this would be great if it exist in the Leaflet core. Google Maps allows you to do this.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
danzelcommented, Dec 16, 2012

It is much cleaner in this case to use the JS object as you get access to the JS object, but you don’t get access to the DOM objects. You can access them at myMarker._icon IIRC, but it’s usually not a good idea.

0reactions
AlainPiloncommented, Dec 16, 2012

Maybe I am missing something but why is it better to append data to JS objects than to the DOM? I found this issue while looking at a way to use the data attribute so my markers can have the same behaviour as their counterparts (somewhere else on the page) when clicked on.

Also, @danzel example does not work for me, I have to do

console.log(a.target.myData.id);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pop-ups—ArcGIS Pro | Documentation
View data attributes in a pop-up ... A pop-up is a read-only display of attribute information. It is a convenient way to identify...
Read more >
Pump Up Your Pop-ups With Arcade FeatureSets and ... - Esri
To do this within one of your own web maps, add a layer which you want to access data from (a contextual layer),...
Read more >
Creating Dynamic Pop-ups in ArcGIS Online Web Maps and ...
This webinar will provide attendees with useful tips and tricks on how to create engaging popups in your ArcGIS Online web maps and...
Read more >
Add a popup to a point on a map - Microsoft Learn
Mouse events are added to the symbol layer to trigger opening and closing the popup. When the marker symbol is hovered, the popup's...
Read more >
ArcGIS Maps - reference layer pop-up
The hosted layer has its pop-up setup to display a single field from the data. However, Power BI does not pick this up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found