Comments (9)
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.
Thanks so much!
from react-map-gl-geocoder.
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.
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.
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.
I'll try removing my dependencies and re-updating!
from react-map-gl-geocoder.
Does the example work for you? If it doesn't, let me know what your search query is.
from react-map-gl-geocoder.
It worked! I just had to remove my node_modules folder and reinstall. :) Thanks so much Sam!
from react-map-gl-geocoder.
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)
- GeoCoder Marker's Styling Not Working HOT 2
- Search Results Not closing, and marker not dropping HOT 9
- Geocoder doesn't appear in Next.js app HOT 1
- Console error passing object to marker prop
- Suggestions are displayed after setting a default input HOT 3
- External geocoder HOT 1
- React 17? HOT 1
- how to active draggable after search HOT 1
- mapbox-gl neccessary dependency? HOT 1
- How to get the current value? HOT 3
- Typescript import issue HOT 1
- Supporting stand-alone Geocoder without map ? HOT 1
- react-map-gl 7 support HOT 7
- Multiple input options in react app HOT 1
- export 'FlyToInterpolator' (imported as 'r') was not found in 'react-map-gl' HOT 2
- Request to upgrade transitive dependency `http-cache-semantics` in `react-map-gl-geocoder` HOT 1
- Menu stays open HOT 2
- Upon passing Marker="true" into geocoder, no point appears HOT 4
- TypeError: Cannot read property 'remove' of undefined __ Cannot read property 'addControl' of null - HOT 6
- Can Not Use react.map.gl.gecoder with Typescript HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-map-gl-geocoder.