When GMSMarker
is clicked and InfoWindow
is opened the camera moves to point where GMSMarker
is at the center of the GMSMapView
. How to change the camera move position that marker is at the bottom when moved?
When I implement GMS didTapMarker
delegate
method without InfoWindow
everything is fine:
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
}
It positions marker on the bottom. But if I return false
it shows InfoWindow and marker is centered again.
mapView.selectedMarker = marker
is missing in didTapMarker
delegate
method. The method should look like this:
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
}