Giter Club home page Giter Club logo

Comments (7)

SamSamskies avatar SamSamskies commented on May 28, 2024 1

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.

from react-map-gl-geocoder.

sos0 avatar sos0 commented on May 28, 2024 1

I followed your example and it worked great! Thank you.

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

Hi @sos0 ,
Currently, it's not possible to change the speed of the animation. I can work on adding that this weekend. For now you could disable the animation by passing in options with flyTo set to false.

<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:
https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md

Thanks for filing the issues 😄

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

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.

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024
<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:
https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md

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.

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

Updated my example to show how to override the default animation speed. https://codesandbox.io/s/vv29y730q3

from react-map-gl-geocoder.

sos0 avatar sos0 commented on May 28, 2024

Thanks! I'll look into this now and ask any follow up questions if I have any.

from react-map-gl-geocoder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.