-
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
On result handler #9
Comments
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. |
Thanks so much! |
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. |
Am I correct in understanding that all I have to do is pass a function to the 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! |
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. |
I'll try removing my dependencies and re-updating! |
Does the example work for you? If it doesn't, let me know what your search query is. |
It worked! I just had to remove my node_modules folder and reinstall. :) Thanks so much Sam! |
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. |
Hello,
Separate question from my other one (#8), how do I add a onResults or onResult handler to the component?
The text was updated successfully, but these errors were encountered: