【问题标题】:Getting layer features with querySourceFeature使用 querySourceFeatures 获取图层特征
【发布时间】:2019-10-07 10:24:50
【问题描述】:

我正在尝试从 Mapbox 样式图层中获取所有功能。我找到了 querySourceFeature() 方法。但是,我无法获得确切的来源。这里是 Mapbox 文档中的简单代码块。

我不使用 GeoJsonSource 进行样式设置,我的意思是我不添加任何 GeoJsonSouce。所以,“source”变量返回“null”,我不明白应该用什么来代替 GeoJsonSource 和“population-source”。

GeoJsonSource source = style.getSourceAs("population-source");
List<Feature> features = source.querySourceFeatures(Expression.get("population"));

综上所述,我想从 Mapbox 样式中获取一层中的所有功能。

【问题讨论】:

    标签: java android mapbox


    【解决方案1】:

    为了获取样式层作为源,我们应该使用VectorSource()

    VectorSource source = style.getSourceAs("composite");

    “composite”是“style.json”中图层的源变量。

    对于querySourceFeatures(),我们应该给layerSource(String[])Expression

    List&lt;Feature&gt; all_features = source.querySourceFeatures(source_layers,Expression);

    “source_layers”是“style.json”中层的源层变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-18
      • 1970-01-01
      • 1970-01-01
      • 2020-11-29
      • 1970-01-01
      • 2019-10-26
      • 2018-07-04
      • 1970-01-01
      相关资源
      最近更新 更多