代码之家  ›  专栏  ›  技术社区  ›  Serge Maslyakov

如何禁用“mglsymbolstylelayer”的群集化功能?

  •  1
  • Serge Maslyakov  · 技术社区  · 7 年前

    环境

    • Mapbox-iOS-SDK 3.7.8

    我试过禁用 MGLSymbolStyleLayer 具有 MGLShapeSource 是的。

    之后 MGLMapView 装了我做的 MGL符号样式层

    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)
    

    但不管怎样,团簇反应总是开着的。 是否可以禁用 MGL符号样式层 是吗?

    1 回复  |  直到 7 年前
        1
  •  2
  •   jmkiley    7 年前

    我还不能复制这个版本,但是 options 是可选的。因此,您应该能够将其设置为 nil 在顺序上看不到聚类。

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

    某些功能可能隐藏以避免图标重叠。如果要允许图标重叠,请设置 iconAllowsOverlap YES 是的。