Я не знаком с картой Google.Маркеры на карте Google перемещаются, когда я увеличиваю. Пожалуйста, смотрите снимок экрана.Есть мысли о том, как заставить маркер удерживать свое место относительно карты?
func getCoordinate( addressString : String,
completionHandler: @escaping(CLLocationCoordinate2D, NSError?) -> Void ) {
let geocoder = CLGeocoder()
geocoder.geocodeAddressString(addressString) { (placemarks, error) in
if error == nil {
if let placemark = placemarks?[0] {
let location = placemark.location!
completionHandler(location.coordinate, nil)
return
}
}
completionHandler(kCLLocationCoordinate2DInvalid, error as NSError?)
}
}
Это мой код:
func determineMyCurrentLocation() {
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
if CLLocationManager.locationServicesEnabled() {
locationManager.startUpdatingLocation()
locationManager.startUpdatingHeading()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
locationManager.delegate = nil
locationManager.stopUpdatingLocation()
let userLocation = locations.last
let lat = (userLocation!.coordinate.latitude)
let long = (userLocation!.coordinate.longitude)
let camera = GMSCameraPosition.camera(withLatitude: lat, longitude: long, zoom: 10.0)
mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
mapView!.isMyLocationEnabled = true
mapView!.animate(to: camera)
view = mapView
showPartyMarkers(lat: lat, long: long)
}
func showPartyMarkers(lat: Double, long: Double) {
mapView!.clear()
for i in 0...properties.count - 1 {
let marker=GMSMarker()
ImageService.getImage(withURL: URL(string: properties[i].gallery[0])!) { (image) in
let customMarker = CustomMarkerView(frame: CGRect(x: 0, y: 0, width: 150 , height: 180), image: image!, borderColor: UIColor.darkGray, tag: i)
marker.iconView=customMarker
}
getCoordinate(addressString: properties[i].address) { (CLLocationCoordinate2D, error) in
print(CLLocationCoordinate2D)
if error != nil {
print(error)
return
}
marker.position = CLLocationCoordinate2D
marker.map = self.mapView
}
}
}
func getCoordinate( addressString : String,
completionHandler: @escaping(CLLocationCoordinate2D, NSError?) -> Void ) {
let geocoder = CLGeocoder()
geocoder.geocodeAddressString(addressString) { (placemarks, error) in
if error == nil {
if let placemark = placemarks?[0] {
let location = placemark.location!
completionHandler(location.coordinate, nil)
return
}
}
completionHandler(kCLLocationCoordinate2DInvalid, error as NSError?)
}
}
Заранее спасибо