Comments (12)
Thanks for reporting this issue.
It looks like react-map-gl places an overlay to capture events. visgl/react-map-gl#304
You could use the containerRef
prop to place the geocoder outside of the map to avoid propagating the events. Example: https://codesandbox.io/s/v0m14q5rly
from react-map-gl-geocoder.
I added an example of how to fix this problem using a custom MapController. https://codesandbox.io/s/react-map-gl-geocoder-ignore-events-example-x652y
from react-map-gl-geocoder.
The solution works well thanks! Could the CustomMapController be something that is exported from this library?
from react-map-gl-geocoder.
Hi @TAQ2, thanks for the idea, but I don't think I want to do that since react-map-gl
is a peer dependency. It's possible that MapController
could have a different API depending on the version of react-map-gl
being used in the app.
Maybe I can update the README instead to include links to all my Code Sandbox examples including this one. That way at least people won't have to dig through past issues to figure out how to do stuff.
from react-map-gl-geocoder.
Yeah that sounds like a good idea :)
from react-map-gl-geocoder.
How would I do this on a custom element with no mapRef and containerRef props?
from react-map-gl-geocoder.
Hi @CSFlorin, what do you mean by do this on a custom element? Also, mapRef
is a required prop.
from react-map-gl-geocoder.
To the example solution above, it only handles the input box itself. When you click on the suggestions, you have the same problem. At first look, it seems like the easiest solution is to just extend what @SamSamskies did and also check for these classes:
mapboxgl-ctrl-geocoder--suggestion-title
and mapboxgl-ctrl-geocoder--suggestion-address
in the custom controller.
from react-map-gl-geocoder.
Hi @kjkurtz, thanks for raising this issue. I didn't know about that. Maybe I can export a helper function that checks if a click was made on any of the geocoder HTML elements. It would be safer because if I ever update the @mapbox/mapbox-gl-geocoder
dependency, the class names could possibly change. It would be better to abstract these class names away from users of this component.
For now, I recommend using the containerRef
option. You don't need a custom controller if you do it that way. If you want the geocoder to appear visually over the map, you can use CSS in your container to achieve that.
from react-map-gl-geocoder.
+1 on the issue, I have the same thing. Let me try the containerRef solution for now, however I do want the geocoder to appear visually over the map.. @SamSamskies if you have the time could you make some sample css on how to achieve that. If not that's ok I will still try, thanks.
EDIT: nevermind, I solved it. First, I used your existing example with containerRef (with the black bar) and modified css to have the container with "position: absolute", added some margins and that did the trick! Also added background: transparent as well. Works great.
from react-map-gl-geocoder.
Hi @axleun, here's an example for you https://codesandbox.io/s/react-map-gl-geocoder-using-containerref-to-ignore-events-rewdh
from react-map-gl-geocoder.
Great work with this library @SamSamskies 👍
I have integrated react-map-gl-geooder
in my webapp as it bundles really well with the react-map-gl
library. I have the following issue, though:
Whlle on a mobile device, swiping up/down the suggestion list triggers map movement instead of hiding the keyboard in order to see the full suggestion list.
On a first note, I applied your suggestion on using the containerRef instead of the mapRef in order to stop gestures from propagating to the map's layers but no luck. I created a custom map controller for pan movements on suggesstion list to stop map movement and it stopped the map from moving (although it still moves when I pan on a random trajectory).
Now what's left is to blur the input field every time the geocoder element (either the input or the suggestions) is panned.
I would really appreciate if you could point me to the right direction about the next steps to hide the keyboard whenver either the input field or the suggestion list is panned.
EDIT: If you agree, this could be a new issue that maybe targets a bit more the real problem here, the input field blur in order to hide the keyboard and show the full suggestion list.
See attachement: https://res.cloudinary.com/dwmew0qd3/video/upload/v1588703418/geocoder-suggestions-bug.mov
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.