单击时将 GMSMarker 置于底部
Position GMSMarker on bottom when clicked
单击 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
}
它将标记定位在底部。但是如果我 return 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
}
单击 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
}
它将标记定位在底部。但是如果我 return 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
}