で作業されていませんが、私のdidLongPressAt座標イベントが機能していません。私はテストのためにその中でprintステートメントを使用しました。 UIViewが追加されました。私はジェスチャーも組み込みましたが、まだ動作していません。 ここに私のコードです。私を助けてください。デフォルトのジェスチャーイベントは、Googleマップ
var mapView=GMSMapView()
var camera = GMSCameraPosition()
let locationmanager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
self.mapView.delegate=self
// Do any additional setup after loading the view.
self.locationmanager.delegate=self
self.locationmanager.desiredAccuracy=kCLLocationAccuracyNearestTenMeters
self.locationmanager.requestWhenInUseAuthorization()
self.locationmanager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
self.showCurrentLocationOnMap()
self.locationmanager.stopUpdatingLocation()
}
func showCurrentLocationOnMap()
{
camera = GMSCameraPosition.camera(withLatitude: (self.locationmanager.location?.coordinate.latitude)!, longitude: (self.locationmanager.location?.coordinate.longitude)!, zoom: 15)
mapView = GMSMapView.map(withFrame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(myView.frame.size.width), height: CGFloat(myView.frame.size.height)), camera: camera)
mapView.settings.myLocationButton=true
mapView.isMyLocationEnabled=true
let marker = GMSMarker()
marker.position=camera.target
marker.snippet="My Current Location"
marker.appearAnimation=GMSMarkerAnimation.pop
marker.map=mapView
myView.addSubview(mapView)
}
func mapView(_ mapView: GMSMapView, didLongPressAt coordinate: CLLocationCoordinate2D) {
print (coordinate.latitude)
print(coordinate.longitude)
}
mapView.animate(with cameraUpdate:GMSCameraUpdate)は機能しません。エラーがアニメーションを呼び出せないことを示しています –
GMSCameraUpdateのインスタンスを作成し、このメソッドに渡す必要があります。上記のコードは単なるプロトタイプでした。 – dRAGONAIR
あなたはあなたの "showCurrentLocationOnMap"のような何かをする必要があります 'let newLocation = CLLocationCoordinate2D(latitude:self.locationmanager.location?coordinate.latitude、self.locationmanager.location?coordinate.longitude:longitude) let cameraPositionUpdate = GMSCameraUpdate.setTarget(newLocation) self.mapView.animate(with:cameraPositionUpdate) ' – dRAGONAIR