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.

No option exists to add an id to divIcon

See original GitHub issue

Per the divIcon documentation, you can add a className but it doesn’t look like you could add an id. Is this possible or could it be logged as a small feature request?

The use case is you have a marker that is specific for one thing and should most logically have an id. You could obviously add a unique className but that’s not the precise use of a class and id’s are faster than classes to select with jQuery, so that would help there.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:2
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jonkoopscommented, Dec 1, 2021

I’m closing this issue as it’s already possible to extend the DivIcon class as per https://github.com/Leaflet/Leaflet/pull/1010#issuecomment-963393644. The createIcon() method returns a HTMLElement that can be modified directly.

0reactions
Falke-Designcommented, Dec 1, 2021

Linking: #1010, #230

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet / JQuery -cannot add or remove class to divIcon marker
Here's a codepen example that shows how to add a class to an SVG. No jQuery required. document.getElementsByTagName('svg')[0].
Read more >
Leaflet geojson layer with customized divIcon for each feature
1 Answer 1 · style option is used for vector layers. Therefore in the case of Point features that are rendered as L.divIcon...
Read more >
Creating a dynamic “JSX” marker with react-leaflet - Medium
A marker identifies a location on a map, and is often identified by an Icon. The default icon from Leaflet. Leaflet provides two...
Read more >
L.DivIcon
Creates a div icon instance with the given options. Options. Option, Type, Description. iconSize, Point, Size of the icon in pixels.
Read more >
Documentation - a JavaScript library for interactive maps
L.map(<String> id, <Map options> options?) ... A value of 0 means the zoom level will not be snapped after fitBounds or a pinch-zoom....
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