No option exists to add an id to divIcon
See original GitHub issuePer 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:
- Created 10 years ago
- Reactions:2
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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. ThecreateIcon()
method returns aHTMLElement
that can be modified directly.Linking: #1010, #230