环境
Mapbox-iOS-SDK 3.7.8
我已尝试使用 MGLShapeSource
禁用 MGLSymbolStyleLayer
的聚类。
MGLMapView
加载后,我创建了 MGLSymbolStyleLayer
private func makeSymbolLayer(withId identifier: String, style: MGLStyle) {
let options = [MGLShapeSourceOption.clustered: false as NSNumber]
let source = MGLShapeSource(identifier: identifier, features: [], options: options)
let layer = MGLSymbolStyleLayer(identifier: identifier, source: source)
style.addSource(source)
style.addLayer(layer)
}
然后,当我从服务器获取数据时,我会填充一个形状。我用不同的图标创建功能。
source.shape = MGLShapeCollectionFeature(shapes: loadedFeatures)
但无论如何,集群化始终处于开启状态。
是否可以禁用 MGLSymbolStyleLayer
的集群化?
最佳答案
我无法重现此问题,但 options
是可选的。因此,您应该能够按顺序将其设置为 nil
并且看不到聚类。
let source = MGLShapeSource(identifier: 标识符, features: [], options: nil)
某些功能可能会隐藏以避免图标重叠。如果你想允许图标重叠,设置 iconAllowsOverlap
到 YES
。
关于ios - 如何禁用 `MGLSymbolStyleLayer` 的集群化功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51088755/