Can I intercept marker deselect when I tap another marker in Google Maps SDK for iOS?

江枫思渺然 提交于 2019-12-01 09:34:09

问题


I know that I can use didTapAtCoordinate that will deselect the marker when I tap else where on the map. But If there are multiple marker and I tap another one (Ex. MarkerA -> MarkerB), Is there any call back when the previous marker DidDeselect?. I look around in GMSMapView the but can't find any thing I can use.

I want to change the marker color or image when it being selected and change it back when another marker select or the marker deselect.

Thank you.


回答1:


The doco for selectedMarker says:

The marker that is selected. Setting this property selects a particular marker, showing an info window on it. If this property is non-nil, setting it to nil deselects the marker, hiding the info window. This property is observable using KVO.

So, you could use Key Value Observing to be notified of changes to selectedMarker. If you use NSKeyValueObservingOptionOld when setting up KVO (described in more detail here), you will be notified of the old value, ie the marker which was deselected.



来源:https://stackoverflow.com/questions/23387044/can-i-intercept-marker-deselect-when-i-tap-another-marker-in-google-maps-sdk-for

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