Chris
Chris

Reputation: 83

Mapbox geocode with Jumpto instead of Flyto?

Mapbox has a default geocoding feature called flyto. It zooms out of your current location pans across the map and zooms in on another location. This looks cool but it seems to run slow with a large data set. Is it possible to change the default geocoding feature to Jumpto instead of Flyto? I've noticed jumpto tends to load faster in other examples with large data.

Upvotes: 2

Views: 1679

Answers (2)

Fragmental
Fragmental

Reputation: 85

Disabling the flyTo will result in the map not moving at all. There is currently no way to make use of a jumpTo animation with the Geocoder Control but what you can do change the animation properties.

As per the documentation, the flyTo parameter accepts an AnimationOptions object as a parameter, where you can set the duration to 0.

const geocoder = new MapboxGeocoder({
  accessToken: MAPBOX_ACCESS_TOKEN,
  mapboxgl: mapboxgl,
  flyTo: { duration: 0 }
});

This will make the animation instantaneous.

Upvotes: 3

AndrewHarvey
AndrewHarvey

Reputation: 3055

See the API documentation https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md there is a flyTo option you can set to false.

Upvotes: 2

Related Questions