我對應用程序使用Google Map和Google-Maps-iOS-Utils。如何在Google Map中顯示羣集時隱藏標記
如何在僅顯示羣集時隱藏標記?
https://developers.google.com/maps/documentation/ios-sdk/utility/marker-clustering
我對應用程序使用Google Map和Google-Maps-iOS-Utils。如何在Google Map中顯示羣集時隱藏標記
如何在僅顯示羣集時隱藏標記?
https://developers.google.com/maps/documentation/ios-sdk/utility/marker-clustering
import UIKit
class CustomClusterRenderer: GMUDefaultClusterRenderer {
let GMUAnimationDuration: Double = 0.5
var mapView: GMSMapView?
override init(mapView: GMSMapView, clusterIconGenerator iconGenerator: GMUClusterIconGenerator) {
super.init(mapView: mapView, clusterIconGenerator: iconGenerator)
self.mapView = mapView
}
func markerWith(position: CLLocationCoordinate2D, from: CLLocationCoordinate2D, userData: AnyObject, clusterIcon: UIImage, animated: Bool) -> GMSMarker {
let initialPosition = animated ? from : position
let marker = GMSMarker(position: initialPosition)
marker.userData = userData
marker.icon = clusterIcon
marker.groundAnchor = CGPoint(x: 0.5, y: 0.5)
marker.map = mapView
if animated {
CATransaction.begin()
CAAnimation.init().duration = GMUAnimationDuration
marker.layer.latitude = position.latitude
marker.layer.longitude = position.longitude
CATransaction.commit()
}
return marker
}
func getCustomUIImageItem(userData: AnyObject) -> UIImage {
if let item = userData as? Marker {
return item.merkerIcon
}
return UIImage()
}
override func shouldRender(as cluster: GMUCluster, atZoom zoom: Float) -> Bool {
print("Zoom Level is \(zoom) , and result is \(zoom<=14)")
return zoom <= 14;
}
}
class Marker: NSObject, GMUClusterItem {
var position: CLLocationCoordinate2D
var estate: Estate
init(estate: Estate) {
self.estate = estate
self.position = CLLocationCoordinate2D(latitude: estate.latitude,longitude: estate.longitude)
}
}
簡單的答案是,轉到您的POD文件或者如果你添加manualy轉到類GMUDefaultClusterRenderer.m
簡單的是,更換頂線
static const NSUInteger kGMUMinClusterSize = 2;
你的萬阿英,蔣達清解決由於
希望這將有助於你
加上類GMUDefaultClusterRenderer.m
static const NSUInteger kGMUMinClusterSize = 2;
問題解決
你意味着你不想一行顯示位置引腳? –
你能提供代碼嗎? –
@DharmeshKheni是 – RaziPour1993