首页 > 解决方案 > 如何禁用“MGLSymbolStyleLayer”的聚类功能?

问题描述

环境

我试图为MGLSymbolStyleLayerwith禁用集群化MGLShapeSource

加载后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

标签: iosswiftmapbox

解决方案


我无法重现此问题,但这options是可选的。因此,您应该能够将其设置为nil按顺序排列,而不会看到集群。

let source = MGLShapeSource(identifier: identifier, features: [], options: nil)

某些功能可能会隐藏以避免图标重叠。如果您想允许图标重叠,请设置iconAllowsOverlapYES


推荐阅读