单击 GMSMarker
并打开 InfoWindow
时,相机移动到 GMSMarker
位于 GMSMapView< 中心的位置
。如何更改移动时标记位于底部的相机移动位置?
当我在没有 InfoWindow
的情况下实现 GMS didTapMarker
delegate
方法时,一切都很好:
func mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker) -> Bool {
var point = mapView.projection.pointForCoordinate(marker.position)
point.y = point.y - 200
let camera = GMSCameraUpdate.setTarget(mapView.projection.coordinateForPoint(point))
mapView.animateWithCameraUpdate(camera)
return true
}
它将标记定位在底部。但是,如果我 返回 false
,它会显示 InfoWindow 并且标记再次居中。
最佳答案
mapView.selectedMarker = marker
在 didTapMarker
delegate
方法中丢失。该方法应如下所示:
func mapView(mapView: GMSMapView, didTapMarker marker: GMSMarker) -> Bool {
var point = mapView.projection.pointForCoordinate(marker.position)
point.y = point.y - 150
let camera = GMSCameraUpdate.setTarget(mapView.projection.coordinateForPoint(point))
mapView.animateWithCameraUpdate(camera)
mapView.selectedMarker = marker
return true
}
关于ios - 单击时将 GMSMarker 置于底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38828600/