【发布时间】:2017-09-25 10:04:41
【问题描述】:
我是开发的初学者,我在我的应用程序视图上添加谷歌地图,按照教程我使用了这个代码
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location: CLLocation = locations.last!
print("Location: \(location)")
let camera = GMSCameraPosition.camera(withLatitude: location.coordinate.latitude,
longitude: location.coordinate.longitude,
zoom: zoomlevel)
let marker = GMSMarker()
marker.title = "My Position"
marker.map = mapView
if mapView.isHidden {
mapView.isHidden = false
mapView.camera = camera
} else {
mapView.animate(to: camera)
}
}
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
switch status {
case .restricted:
print("Location access was restricted.")
case .denied:
print("User denied access to location.")
mapView.isHidden = false
case .notDetermined:
print("Location status not determined.")
case .authorizedAlways: fallthrough
case .authorizedWhenInUse:
print("Location status is OK.")
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
locationManager.stopUpdatingLocation()
print("Error: \(error)")
}
要查找用户位置,现在我想在地图上查看距离用户位置 X 距离的地点(谷歌地点),我该怎么做?我在 google 地方文档上搜索但没有找到有效的答案
【问题讨论】:
-
这是您要找的东西:[stackoverflow.com/questions/44333550/…??
标签: ios swift xcode google-maps