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.

Remove marker Bug if map.markerZoomAnimation = false

See original GitHub issue

Only tested on Master. If you initialize the map with markerZoomAnimation = false the map will fire the event zoomanim even for the removed markers when you zoom in and out.

https://playground-leaflet.rhcloud.com/juzu/1/edit?html,js,output

Zoom in and out on that map for 10 seconds, no problems. After 10 seconds the marker is removed. Now if you try to zoom you get an error in the console: error Script error. (line 0) I don’t know how to link proper errors from that website, but on my website this is the error i get in the console: 'Uncaught TypeError: Cannot read property '_latLngToNewLayerPoint' of null @ https://github.com/Leaflet/Leaflet/blob/master/src/layer/marker/Marker.js#L290`

I think this is happening because when we add a marker this is happening: https://github.com/Leaflet/Leaflet/blob/master/src/layer/Layer.js#L86 is True so https://github.com/Leaflet/Leaflet/blob/master/src/layer/marker/Marker.js#L124 gets set. so it’s registering zoomanim https://github.com/Leaflet/Leaflet/blob/master/src/layer/Layer.js#L89 Then https://github.com/Leaflet/Leaflet/blob/master/src/layer/marker/Marker.js#L101 is False But when we remove the marker this is what is going on: https://github.com/Leaflet/Leaflet/blob/master/src/layer/Layer.js#L171 is going to: https://github.com/Leaflet/Leaflet/blob/master/src/layer/marker/Marker.js#L123 which is false so it’s not removing the handler for the zoomanim event.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Fate-uicommented, Jun 10, 2022

I solved the question by adding this code to project (anywhere , just sure it will be used)

L.Popup.prototype._animateZoom = function (e) {
  if (!this._map) {
    return
  }
  var pos = this._map._latLngToNewLayerPoint(this._latlng, e.zoom, e.center),
    anchor = this._getAnchor()
  L.DomUtil.setPosition(this._container, pos.add(anchor))
}
1reaction
andresgwellcommented, May 16, 2022

is happenig again

Read more comments on GitHub >

github_iconTop Results From Across the Web

Map markers don't disappear when removed from item frames
The Bug: The map marker that appears when placing maps into an item frame no longer disappears when the map is removed. Steps...
Read more >
Leaflet - a JavaScript library for interactive maps - GitHub Pages
markerZoomAnimation, Boolean, depends, Whether markers animate their zoom with the ... unload, Event, Fired when the map is destroyed with remove method.
Read more >
Leaflet 1.6 documentation - DevDocs
markerZoomAnimation, Boolean, true, Whether markers animate their zoom with the zoom animation, if disabled they will disappear for the length of the ...
Read more >
leaflet - How can the map be centered at a moving marker ...
Using Leaflet marker's move event. var map = L.map('Lmap').
Read more >
Leaflet Maps Marker v2.7.1 is available
If you have thousands of markers on a map though, you can turn off the marker animation if it gets slow with the...
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