ios - 如何禁用 `MGLSymbolStyleLayer` 的集群化功能?

标签 ios swift mapbox

环境

  • 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)

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

关于ios - 如何禁用 `MGLSymbolStyleLayer` 的集群化功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51088755/

相关文章:

ios - 如何在 XMPP 中阻止匿名用户

javascript - 将文本标签与 Mapbox 静态图像 API geojson 结合使用

ios - 使用 Swift 和 KissXML 创建 XML : example?

ios - Swift/IOS 如何使用观察者进行更新

swift - 在 Swift 中编写自定义访问运算符

ios - 新手,核心数据实例化托管对象

ios - 使用 Swift 解析登录

javascript - Bootstrap 事件按钮状态持续存在

android - MapFragment getMap() 返回 null (mapBox)

android - 我应该在 iOS Android 应用程序上使用什么加密方法 : AES128 or 3DES