Comments (8)
@mark-rodgers just published v1.8.0. Now you should be able to just do this and the weird behavior of the viewport updating even when passing a noop to onViewportChange
is gone. I may not have to make a version 2 after all. 😄
handleGeocoderResult = result => {
this.setState({
searchLngLat: result.result.center
});
};
<Geocoder
mapRef={this.mapRef}
onResult={this.handleGeocoderResult}
mapboxApiAccessToken={"***"}/>
Let me know if you have any other problems.
from react-map-gl-geocoder.
Hi @mark-rodgers, sorry, but I don't think that's possible. You'll probably need to build a custom component to do that using the Mapbox geocoding API. https://docs.mapbox.com/api/search/#geocoding
You could prob borrow a lot of code from https://github.com/mapbox/mapbox-gl-geocoder/blob/master/lib/index.js
from react-map-gl-geocoder.
@mark-rodgers if you can access all the config settings from the geocoder-api, you can set flyTo to be false, which should do what you are looking for, no?
https://github.com/mapbox/mapbox-gl-geocoder/blob/master/API.md
from react-map-gl-geocoder.
@easherma you can actually pass flyTo
down as a prop, but unfortunately that only prevents the animation from happening. It will still go to the location that is searched for.
Ideally, this component shouldn't move if you pass in a noop as the onViewportChange
prop value. However, since I'm using the mapbox-gl-geocoder object to do most of the heavy lifting, I don't think that's possible. If I ever get around to writing a version 2 of this component, I plan to remove the mapbox-gl-geocoder dependency. Then I'd be able to get rid of this unexpected behavior.
from react-map-gl-geocoder.
@easherma you're actually right. I misunderstood how flyTo
works. Sorry, I'm a dummy.
@mark-rodgers You have to set flyTo
to false and also pass in a noop to onViewportChange
.
handleGeocoderResult = result => {
this.setState({
searchLngLat: result.result.center
});
};
<Geocoder
mapRef={this.mapRef}
onViewportChange={() => {}}
flyTo={false}
onResult={this.handleGeocoderResult}
mapboxApiAccessToken={"***"}/>
from react-map-gl-geocoder.
@mark-rodgers I'm going to remove the flyTo
param as that should always be false. This is a bug in my code due to my misunderstanding of what the flyTo
option does. onViewportChange
should be the only way to update the viewport. I'll also default onViewportChange
to a noop. That way you won't even need to provide those props.
from react-map-gl-geocoder.
Awesome! I’ll checkout the latest release soon, I’m sure this update will be useful to many!
from react-map-gl-geocoder.
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.