我正在为我的一个项目使用Yandex Mapkit iOS SDK。
似乎 SDK 允许添加地标是一个集群。Bu 我不能像添加地标一样添加自定义地标与 userData mapObject
。我想检测标记上的点击动作。
// adding markers as mapobjects:
let point = YMKPoint(coordinate: CLLocationCoordinate2D(latitude: Double(hit.geom!.lat ?? 0), longitude: Double(hit.geom?.lon ?? 0)))
let placemark: YMKPlacemarkMapObject
self.mapObjects = self.mapView.mapWindow.map.mapObjects
placemark = mapObjects!.addPlacemark(with: point, image: #imageLiteral(resourceName: "marker"))
placemark.userData = MarkerUserData(id: Int(hit.id!)!, description: hit.plate!)
placemark.isDraggable = false
placemark.addTapListener(with: self)
mapObjects!.addListener(with: self)
在集群中添加标记,标记只能使用YMKPoint
. 我找不到placemark
在集群内添加对象的方法
let point = YMKPoint(coordinate: CLLocationCoordinate2D(latitude: Double(hit.geom!.lat ?? 0), longitude: Double(hit.geom?.lon ?? 0)))
let placemark: YMKPlacemarkMapObject
collection.addPlacemark(with: point, image: #imageLiteral(resourceName: "marker"))
// Placemarks won't be displayed until this method is called. It must be also called
// to force clusters update after collection change
collection.clusterPlacemarks(withClusterRadius: 20, minZoom: 5)