Giter VIP home page Giter VIP logo

Comments (11)

madrussa avatar madrussa commented on June 10, 2024 36

I've found a solution that seems to work nicely using the static preventMapHitsFrom and preventMapHitsAndGesturesFrom methods from https://developers.google.com/maps/documentation/javascript/reference/overlay-view#OverlayView.preventMapHitsFrom

In your component or HTML Element within your OverlayView you can call preventMapHitsFrom on your element that you don't want your mouse or touch events filtering down to the map

class OverlayInner extends React.Component {
  handleClick = () => {
    console.log('I still work');
  }
  render () {
    <div
      ref={ ref => ref && google.maps.OverlayView.preventMapHitsFrom(ref) }
      onClick={this.handleClick}
    />
      Dont click map
    </div>
  }
}

Your standard onClick events will continue to work.

from react-google-maps.

tomhalley avatar tomhalley commented on June 10, 2024 3

Wow... is that new @madrussa? That's worked perfectly.

I spent over a year looking for a fix for that...

Damn...

from react-google-maps.

ksavenkov avatar ksavenkov commented on June 10, 2024 2

Actually, I've found a workaround: added overlayHovered flag to the state and check it in handleMapClick function.

from react-google-maps.

ksavenkov avatar ksavenkov commented on June 10, 2024

Second that. As I understand, this is not the intended behavior of Google Maps. It breaks the use case when OverlayView is used to display a menu, which is closed by clicking on the map.

from react-google-maps.

tomchentw avatar tomchentw commented on June 10, 2024

I've noticed the same behavior in the #basics/overlay-view example.

from react-google-maps.

juanbiltes avatar juanbiltes commented on June 10, 2024

Having the same issue here, was there a better solution for this?

from react-google-maps.

tomchentw avatar tomchentw commented on June 10, 2024

Feel free to submit a PR. Close for now

We're also looking for maintainers. Involve in #266 to help strengthen our community!

from react-google-maps.

urikphytech avatar urikphytech commented on June 10, 2024

Anyone find a good solution for this?

from react-google-maps.

tomhalley avatar tomhalley commented on June 10, 2024

This seems to be a bug inherent in google maps.

One guy said he found a fix, but that didn't work for me...

And the hover solution suggested by @ksavenkov and another guy in this stackoverflow thread doesn't work on mobile, so not a long term fix.

I've had to deal with this issue a year ago, and now coming back to it again. I think it's getting to a point where I'd pay money

from react-google-maps.

ufon avatar ufon commented on June 10, 2024

up please

from react-google-maps.

madrussa avatar madrussa commented on June 10, 2024

Yeah it looks new. I can see it in 3.33 but not 3.32. My only concern is that it's a black hole and it could lead to memory leaks... as you feed it references, but what happens when they remove?

from react-google-maps.

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.