Search code examples
iosswiftgoogle-maps-sdk-ios

Prevent GMSMarker from repositioning camera view on tap


I am creating a custom marker like below,

let am = GMSMarker(position: CLLocationCoordinate2DMake(22.213232, 144.332233))
am.title = "some title"
am.icon = UIImage(named: "marker_pointer")
am.map = self.map

The above marker on tap, repositions the camera view and places itself in the centre of the map.

Is there a way to prevent this behaviour?


Solution

  • Found out (from @Craig's comment above) that there is a way to do this with GMSMapView delegate method implementation:

    func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
            mapView.selectedMarker = marker
            return true
    }