Why I need to tap twice a GMSMarker when it is overlapping a GMSOverlay to show its info window?

佐手、 提交于 2021-01-28 04:43:06

问题


I have an GMSOverlay in a GMSMapView, so I listen to taps into it with the method:

func mapView(_ mapView: GMSMapView, didTap overlay: GMSOverlay) {
    // Overlay was tapped
}

Then I want a GMSMarker to be painted over the GMSOverlay, and I listen to taps into it with the method:

func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
    // Marker was tapped
    return false
}

Every time the listener of the marker is called, its info window hides (if it's shown) or shows (if it's hidden).

The problem is that the listener of the marker is not called every time I tap it.

Step by step:

  1. Tap in the marker:

    • The info window shows because the listener of the marker is called.
    • The listener of the overlay is not called.
  2. Tap in the marker:

    • The info window doesn't hides (it should) because the listener of the marker is not called.
    • The listener of the overlay is called (it shouldn't).
  3. Tap in the marker:

    • The info window hides because the listener of the marker is called.
    • The listener of the overlay is not called.
  4. Tap in the marker:

    • The info window doesn't show (it should) because the listener of the marker is not called.
    • The listener of the overlay is called (it shouldn't).
  5. Tap in the marker: step 1.

  6. Tap in the marker: step 2.

  7. Tap in the marker: step 3.

  8. Tap in the marker: step 4.

... and so on ...

In brief:

After the first tap, I need to tap two times the marker to hide or show the info window.

来源:https://stackoverflow.com/questions/50220552/why-i-need-to-tap-twice-a-gmsmarker-when-it-is-overlapping-a-gmsoverlay-to-show

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!