Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GopherJ/ab372c59808687f780244199aee8e747 to your computer and use it in GitHub Desktop.
Save GopherJ/ab372c59808687f780244199aee8e747 to your computer and use it in GitHub Desktop.
Smooth animation of changing Leaflet marker's position on setLatLng
// just include d3js and add animaDur in ms to marker's option
L.SVG.prototype._setPath = function(layer,path){
if(layer.options.animaDur)
d3.select(layer._path).transition().duration(layer.options.animaDur).ease('linear').attr('d',path)
else
layer._path.setAttribute('d', path);
}
@GopherJ
Copy link
Author

GopherJ commented Oct 4, 2018

.leaflet-marker-pane > * {
  -webkit-transition: transform 0.3s linear;
  -moz-transition: transform 0.3s linear;
  -o-transition: transform 0.3s linear;
  -ms-transition: transform 0.3s linear;
  transition: transform 0.3s linear;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment