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.

not save marker icon class when zoom

See original GitHub issue
  • Leaflet version 0.77
  • Leaflet.MarkerCluster version 0.72
  • Browser (with version) I’m using: all (ex. chrome 55.0.2883.87 (64-bit))
  • OS/Platform (with version) I’m using: Ubuntu 16.04

I am using markercluster plugin step 1 I create marker

var marker = L.marker(
                    [this.lat, this.lon],
                    {icon: icon, zIndexOffset: 100, 
                    riseOnHover: true}
                );

step 2 Add marker to clustering

step 3 Wnen click to marker, i add className to marker marker._icon.className = marker._icon.className + ' visited';

the className will change(will add ‘visited’ className)

step 4. zoom ‘-’ in map, marker’s icons hide in map and clustering icon is show step 5. zoom ‘+’ in map, clustering icon is hide, marker’s icons is show

But clicked marker will not save new classname ‘visited’

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
danzelcommented, Feb 15, 2017

That isn’t a supported way to add classes to icons. That hack won’t work with markercluster as we remove and add markers from the map, when this happens the class will be removed (You can reproduce this by setting the class, removing the marker from the map then re-adding it). You need to change the classes properly if you want them to be maintained.

0reactions
danzelcommented, Feb 15, 2017

Use marker.setIcon to change the icon

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent marker from scaling when zoom out - Stack Overflow
Based on your comment: Yes, you can solve it with a marker, but there is no 'ready-to-use' option in the MarkerOptions.
Read more >
Show/hide markers depending on zoom-level [duplicate]
I would like to show icons if the user zooms to level 7 or more and hide the markers when zoom level is...
Read more >
Enabling or disabling annotation tools for meetings
Sign in to the Zoom web portal. · In the navigation panel, click Settings. · Click the Meeting tab. · Under In Meeting...
Read more >
Scaling markers with zoom - Google Groups
MarkerClusterer. It won't scale your icons, but it will "group" icons ... save by looping through every marker when zoom level is changed...
Read more >
Info Windows | Maps JavaScript API - Google Developers
Typically you will attach an info window to a marker, but you can also attach an info window to a ... The InfoWindow...
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