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.

Implement zoom/pan options in L.Map.flyTo()

See original GitHub issue

For API consistency, L.Map.flyTo() should take an options argument with the common pan/zoom options.

Also for API consistency, L.Map.flyTo() should return this.

(Also, make L.Map.flyToBounds() pass its options to L.Map.flyTo())

At least the options to not perform animations should be respected, and it would be nice to specify a custom animation time. I don’t think there’s an immediate need for the rest of the zoom/pan options.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
almereydacommented, Oct 8, 2015

If someone stumbles here some day, a duration key for the options object is implemented in https://github.com/Leaflet/Leaflet/blob/a54c2392389982dc618ba94b50ee8fbcb26f7949/src/map/anim/Map.FlyTo.js#L44

0reactions
CoryLRcommented, Mar 5, 2018

@almereyda

I was that guy who stumbled here some day. You are a god, good sir.

Here was my implementation:

map.flyTo([41, -96], 5, { duration: 0.8, }) Works great! The lower the number, the faster the speed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I zoom/Pan to a Leaflet Map, such that the given point ...
Leaflet-active-area: This plugin allows you to use a smaller portion of the map as an active area. All positioning methods (setView, fitBounds, ...
Read more >
Documentation - a JavaScript library for interactive maps
flyTo (<LatLng> latlng, <Number> zoom?, <Zoom/pan options> options?) this. Sets the view of the map (geographical center and zoom) performing a smooth pan-zoom ......
Read more >
L.Map - WRLD3D
flyTo (<LatLng> latlng, <Number> zoom?, <Zoom/pan options> options?) this. Sets the view of the map (geographical center and zoom) performing a smooth pan-zoom ......
Read more >
Animated setView() in Leaflet - Stack Overflow
The duration of any animated zoom is hard-coded to be 0.25s, and because setView accepts zoom/pan options, which do not include duration ...
Read more >
Slowly fly to a location | Mapbox GL JS
Use flyTo with flyOptions to slowly zoom to a location. ... These options control the camera position after animation. const start = {....
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