【发布时间】:2016-06-11 06:47:25
【问题描述】:
我无法在谷歌地图中快速添加长触摸标记 我尝试了很多代码,但它对我不起作用 我该怎么办!?
override func viewDidLoad() {
super.viewDidLoad()
GMSServices.provideAPIKey("AIzaSyBw95wEhcSiSBmPWuYkiK0_IBnZQK-Lm7I")
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
print("Error" + error.description)
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation = locations.last
let center = CLLocationCoordinate2D(latitude: userLocation!.coordinate.latitude, longitude: userLocation!.coordinate.longitude)
let camera = GMSCameraPosition.cameraWithLatitude(userLocation!.coordinate.latitude,
longitude: userLocation!.coordinate.longitude, zoom: 16)
let mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
mapView.myLocationEnabled = true
mapView.settings.myLocationButton = true
view = mapView
let position = CLLocationCoordinate2DMake(10, 10)
let marker = GMSMarker(position: position)
marker.opacity = 0.6
marker.position = center
marker.title = "Current Location"
marker.snippet = ""
marker.map = mapView
//mapView.clear()
}
蚂蚁帮助将不胜感激
【问题讨论】:
-
您要拖动现有标记还是要在地图上添加新标记?
-
新标记!目的地
-
您想在长按上添加标记,而不是在地图视图上单击一次。
-
是的!现在我该怎么办!?它的代码是什么?!
-
试试我的答案,让我知道它是否有效。
标签: ios swift google-maps marker