My app starts up at the user's location, however, every time the user moves the map's camera updates to their location. I want it to load to their location, but then allow them to freely browse the map even if their location is moving. Similar to the behavior exhibited in the Google Maps app. I'm using a KVO to gather the location within the viewDidLoad()
function. That line looks like this:
mapView.isMyLocationEnabled = true
self.mapView.addObserver(self, forKeyPath: "myLocation", options: NSKeyValueObservingOptions.new, context: nil)
Here's my code of the observe function:
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
guard let update = change, let myLocation = update[NSKeyValueChangeKey.newKey] as? CLLocation else {
print("Location not found")
return
}
self.mapView.camera = GMSCameraPosition.camera(withTarget: myLocation.coordinate, zoom: 14)
}
What needs to change to make it meet the criteria mentioned above.