0
マップを移動したときにいつでもマップがユーザーの場所に戻るのを止めることはできますか?その責任 行は次のとおりです。iosmapをズームまたは移動すると、常にユーザーの位置にジャンプSwift
func locationAuthStatus(){
if CLLocationManager.authorizationStatus() == .authorizedWhenInUse{
map.showsUserLocation = true
} else {
locationManager.requestWhenInUseAuthorization()
}
}
func centerMapOnLocation(location:CLLocation){
let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate, regionRadius * 2 , regionRadius * 2)
map.setRegion(coordinateRegion, animated: true)
}
func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation){
if let location = userLocation.location {
//this is the place where you get the new location
print("\(location.coordinate.latitude) ")
print("\(location.coordinate.longitude)")
}
if let loc = userLocation.location {
centerMapOnLocation(location: loc)
locationManager.stopUpdatingLocation()
}
}
私は(locationManager.stopUpdationglocationを考えて)この問題を扱うが、マップが移動したとき、彼は即座にそれを更新しているかのように思えるでしょう。 地図のように、時々ユーザーの場所を更新する必要があります。