Как сделать так, чтобы аннотации, отображаемые на объектах на карте, увеличивались в размере при нажатии
Пожалуйста, помогите нам решить следующую проблему. Как сделать так, чтобы аннотации, отображаемые на объектах на карте, увеличивались в размере при нажатии. Все работает, если у нас есть один и тот же тип маркеров, но, например, если я беру 5 маркеров и рисую разные маркеры при каждом щелчке, тогда маркеры не меняются и раскрашивают маркеры друг друга (увеличение обычно увеличивается)
func mapView(_ mapView: MGLMapView, didDeselect annotation: MGLAnnotation) {
self.currentAnnotation = nil
self.printPoiImage(with: imageName, annotation: annotation, mapView: mapView)
}
private func printPoiImage(with name: String, annotation: MGLAnnotation, mapView: MGLMapView) { let id = "(annotation.coordinate.latitude)+(annotation.coordinate.longitude)" let annotationImage = mapView.dequeueReusableAnnotationImage(withIdentifier: id) annotationImage?.image = UIImage(named: name) }
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
if self.currentAnnotation == nil {
self.currentAnnotation = annotation
self.printPoiImage(with: imageName+"b", annotation: annotation, mapView: mapView)
}
}
func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage? { let id = "(annotation.coordinate.latitude)+(annotation.coordinate.longitude)" var annotationImage = mapView.dequeueReusableAnnotationImage(withIdentifier: id)
var image: UIImage?
if self.currentAnnotation == nil {
image = UIImage(named: imageName)
} else {
image = UIImage(named: imageName+"b")
}
guard var imageWrap = image else { return nil }
imageWrap = imageWrap.withAlignmentRectInsets(UIEdgeInsets(top: 0, left: 0, bottom: imageWrap.size.height/2, right: 0))
annotationImage = MGLAnnotationImage(image: imageWrap, reuseIdentifier: id)
return annotationImage
}
var mapView: NavigationMapView?
override func viewDidLoad() { super.viewDidLoad()
mapView = NavigationMapView(frame: view.bounds, styleURL: MGLStyle.streetsStyleURL)
mapView!.autoresizingMask = [.flexibleWidth, .flexibleHeight]
mapView!.delegate = self
mapView!.userTrackingMode = .follow
mapView!.compassViewMargins = CGPoint(x: 10, y: 55)
mapView?.navigationMapViewDelegate = self
}