Giter Club home page Giter Club logo

Comments (12)

SamSamskies avatar SamSamskies commented on May 28, 2024 1

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.

SamSamskies avatar SamSamskies commented on May 28, 2024

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.

TAQ2 avatar TAQ2 commented on May 28, 2024

The solution works well thanks! Could the CustomMapController be something that is exported from this library?

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

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.

TAQ2 avatar TAQ2 commented on May 28, 2024

Yeah that sounds like a good idea :)

from react-map-gl-geocoder.

CSFlorin avatar CSFlorin commented on May 28, 2024

How would I do this on a custom element with no mapRef and containerRef props?

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on May 28, 2024

Hi @CSFlorin, what do you mean by do this on a custom element? Also, mapRef is a required prop.

from react-map-gl-geocoder.

kjkurtz avatar kjkurtz commented on May 28, 2024

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.

SamSamskies avatar SamSamskies commented on May 28, 2024

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.

axleun avatar axleun commented on May 28, 2024

+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.

SamSamskies avatar SamSamskies commented on May 28, 2024

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.

timpegas avatar timpegas commented on May 28, 2024

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)

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.