에서 작동하지 않습니다하지만 내 didLongPressAt 좌표 이벤트가 작동하지 않습니다. 테스트를 위해 print 문을 사용했습니다. UIView가 추가되었습니다. 내장 제스처도 사용했지만 여전히 작동하지 않습니다. 내 코드는 다음과 같습니다. 제발 도와주세요.기본 제스처 이벤트는 GoogleMap으로
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" 에서 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