Giter Club home page Giter Club logo

Comments (9)

SamSamskies avatar SamSamskies commented on May 28, 2024

There's not an easy way to do this right now. I'll try and work on adding the ability to pass these in as props this weekend.

from react-map-gl-geocoder.

sos0 avatar sos0 commented on May 28, 2024

Thanks so much!

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

I added props for onResults and onResult in the latest version. README is updated with all available props. Let me know if you have any problems.

from react-map-gl-geocoder.

sos0 avatar sos0 commented on May 28, 2024

Am I correct in understanding that all I have to do is pass a function to the onResult prop to achieve the same result as this example?

I tried this and nothing got printed after searching + selecting a result:

_onGeocoderResult = (results) => {
  console.log(results);
}
// ... a bunch of code and ReactMapGL wrapper 
<Geocoder mapRef={this.mapRef}
  onResult={this._onGeocoderResult}
  onViewportChange={this._handleGeocoderViewportChange}
  mapboxApiAccessToken={config.MAPBOX_PUBLIC_TOKEN} />

Again, thanks so much for your help!

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

That should work. Could you verify that you're using v1.4.5?

See example here: https://codesandbox.io/s/0vpoxn0n9l

I just noticed there's an existing bug with mapbox-gl-geocoder that causes onResult to fire twice. mapbox/mapbox-gl-geocoder#99.

from react-map-gl-geocoder.

sos0 avatar sos0 commented on May 28, 2024

I'll try removing my dependencies and re-updating!

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

Does the example work for you? If it doesn't, let me know what your search query is.

from react-map-gl-geocoder.

sos0 avatar sos0 commented on May 28, 2024

It worked! I just had to remove my node_modules folder and reinstall. :) Thanks so much Sam!

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

No problem. Let me know if that bug causing the event to fire twice is a problem for you. I can try and help them fix the bug or figure out a workaround if it is.

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.