지도가 항상 사용자 위치의 가운데에 오도록하고 싶지만 항상 정확한 확대/축소 수준으로 유지하려고합니다. 이 answer에서 얻은 것은 사용자 위치를 확대하지 않고 userTrackingMode
을 사용할 수 없다는 것입니다. iOS -지도 사용자 위치가 중앙에 맞지 않음
CLLocationManager
기능
didUpdateLocations
에서 위치를 얻을
locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
에
manager.location?.coordinate
이
locations.last?.coordinate
과 다른 점이다 사용자의 위치
func updateRegion(withUserLocation userLocation: CLLocationCoordinate2D) {
var region = MKCoordinateRegion.init(center: userLocation, span: MapBodyViewConstants.zoomLevel)
// Avoid random spanning on the map by setting the region's span to be the same with the map's span
region.span = mapView.region.span
mapView.setRegion(region, animated: true)
}
를 따라 해결 방법을 만들었습니다. 그것은 작은 차이지만, 여전히 차이가 있습니다 (나는 와이파이와의 차이점을 발견 할뿐입니다).
왜 차이가 있으며 어떤 것을 사용해야합니까? 일부 연구 후 나는 locations.last.coordinate
을 선호하지만 확실하지는 않습니다 (파란색 사용자 도트는 관리자의 위치를 사용하지만 이것에 대해서는 확실하지 않다고 생각합니다)
하나 더 질문 : iOS를 사용하여지도 사용자에게 파란색 점 위치를 부여 하시겠습니까? 그것은 locationManager 좌표 또는 무엇입니까? 또한 내가 언급해야한다고 생각 :
나는
편집이 ... 질문은 충분히 명확 바랍니다. 문제는 MKMapViewDelegate
방법 mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation)
에 없습니다. 그건 잘 작동합니다. 그러나 어느 시점에서 내가 앱을 시작할 때 CLLocationManager
의 위치를 사용하고 그 곳에서 문제가 발생합니다