Working with Markers

Last updated:

  1. Developing on the new Arm-based Apple Silicon (M1) Macs requires building and running on a physical iOS device or using an iOS simulator running iOS 13.7, e.g. iPhone 11. This is a temporary limitation in Google Maps SDK for iOS, and as such also a limitation in MapsIndoors, due to the dependency to Google Maps.
  2. Note: Due to a bug in CocoaPods it is necessary to include the post_install hook in your Podfile described in the PodFile post_install wiki.

Getting Marker from Location

If a MPLocation has been displayed on a map, the marker can be retrieved using location.marker. On the opposite, get a MPLocation from a GMSMarker using getLocation(marker: GMSMarker) on MPMapControl:

myMapControl.getLocation(marker : GMSMarker!)

Handling Marker Selections

Detecting the user tapping a marker or an infowindow is part of the Google Maps SDK for iOS. Assign myGMSMapView.delegate and implementing the methods: mapView.didTapMarker(marker: GMSMarker) and mapView.didTapInfoWindowOfMarker(marker: GMSMarker)

func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
let location = mapControl?.getLocation(marker)
if location != nil {
myTextLabel.text = location!.name
}
return false
}

func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) -> Bool {
let location = mapControl?.getLocation(marker)
if location != nil {
myTextLabel.text = location!.name
}
return false
}