I am using a Google Maps Street View in Swift and am trying to find a way to add a compass button or a constant compass.
Simply put, as the user clicks and travels through the streets on the screen, if they hit the compass button at any time it will display their current compass heading (IE: North East).
I have a simple view attached to an outlet:
@IBOutlet weak var panoramaView: GMSPanoramaView!
Loaded like:
panoramaView.moveNearCoordinate(CLLocationCoordinate2D(latitude: latitude, longitude: longitude))
It seems there is an option for a compass if you are using other types of map views but I can find any options for a compass on GMSPanoramaView.
I can get the users current position using:
func panoramaView(_ view: GMSPanoramaView, didMoveTo panorama: GMSPanorama?) {
//print("Current Position: \(panorama?.coordinate.latitude ?? 0.0)")
latitude = panorama?.coordinate.latitude ?? 0.0
longitude = panorama?.coordinate.longitude ?? 0.0
}
The rest I am stumped with. Those seem to be the only variables I can access. Does anyone know how I would move forward and turn this into a compass heading?
Any help would be greatly appreaciated.