-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animation speed settings #8
Comments
Hi @sos0 , <Geocoder options={{ flyTo: false }} mapRef={this.mapRef} onViewportChange={this._onViewportChange} mapboxApiAccessToken={MAPBOX_TOKEN} /> I haven't documented it, but any options you pass to the component are used to instantiate the mapbox-gl-geocoder instance. I'll work on adding this information to the docs as well. mapbox-gl-geocoder API: Thanks for filing the issues 😄 |
I looked into this more and the map is the one that should be dictating the speed of the animation by setting the transitionDuration prop on the React MapGL element. I will be removing the default animation in the next release. For now, you can work around my mistake by setting the transitionInterpolator and transitionDuration AFTER spreading this.state.viewport as in the example below. Once I remove the default animation that I forced by passing the transitionInterpolator and transitionDuration to onViewportChange, the order of the of the transitionInterpolator and transitionDuration props on MapGL won't matter. <MapGL
ref={this.mapRef}
{...this.state.viewport}
transitionInterpolator={new FlyToInterpolator()}
transitionDuration={3000}
onViewportChange={this._onViewportChange}
mapboxApiAccessToken={MAPBOX_TOKEN}>
<Geocoder mapRef={this.mapRef} onViewportChange={this._onViewportChange} mapboxApiAccessToken={MAPBOX_TOKEN} />
</MapGL> The FlyToInterpolator can be imported from react-map-gl. import MapGL, { FlyToInterpolator } from 'react-map-gl' UPDATE: Don't do this. I realized that this changes the duration of panning and zooming the map even with just the mouse. |
Actually, I'm going to leave the default animation in as long as flyTo option is not set to false. I'll update the example in the README with a better way to override the transitionDuration. |
I think I'm going to change this. I was just being lazy. Probably going to make each option a prop instead of passing down a whole options object. |
Updated my example to show how to override the default animation speed. https://codesandbox.io/s/vv29y730q3 |
Thanks! I'll look into this now and ask any follow up questions if I have any. |
I followed your example and it worked great! Thank you. |
Hi @SamSamskies,
I just integrated this into my project and noticed that the animation is very slow when updating location. Is there a way to change the settings to update this? Thanks for your hard work!
The text was updated successfully, but these errors were encountered: