2017-04-21 7 views
4

この例では、この例に加えて、マーカーをクラスタ化するためにこのios-sdk-examples > ClusteringExampleを使用しています(各マーカーに独自のUIImageがあることを意味します)。iOS - クラスタ化されたマップボックス、MGLSymbolStyleLayerがカスタム画像を表示しない

let source = MGLShapeSource(identifier: "clusteredPorts", features: self.features, options: [.clustered: true, .clusterRadius: 22]) 
style.addSource(source) 

// remoteImages is an array of tuple [(image: UIImage, key: String)] 
remoteImages.forEach { item in 
    mapView.style!.setImage(item.image, forName: item.key) 
    let layer = MGLSymbolStyleLayer(identifier: item.key, source: source) 
    layer.iconImageName = MGLStyleValue(rawValue: item.key as NSString) 
    layer.predicate = NSPredicate(format: "%K != YES", "cluster") 
    style.addLayer(layer) 
} 

しかし、コードの上のすべてのクラスタ化されていないマーカー(スクリーンショット添付)のための1つのUIImage、私はこれらのカスタムイメージを指定する必要が任意のアイデアを示しています。次のことを試してみましたか?

アップデート-1: self.featuresが配列[MGLPointFeature]で、各MGLPointFeatureは、次のより多くの何もしています:

let feature = MGLPointFeature() 
feature.coordinate = CLLocationCoordinate2D(latitude: LatValue, longitude: LngValue) 
feature.attributes = ["id": IntegerValue] 

enter image description here

+0

これを解決できるのはどこですか? –

答えて

-1

あなたはクラスタ型マーカーを表示したい場合は、私が思うに、あなたを」書く必要があります

%K == YES%K != YESではありません。

layer.predicate = NSPredicate(format: "%K == YES", "cluster") 
+0

クラスタ化されたレイヤーに%K == YESが使用されています。元の例https://www.mapbox.com/ios-sdk/examples/clustering/ – AamirR

関連する問題