从GeoJsonSource获取所有功能

时间:2017-08-25 07:32:40

标签: android mapbox geojson mapbox-android

我想从GeoJsonSource获取所有功能,我的代码是:

GeoJsonSource geoJsonSource = new GeoJsonSource("source", loadJsonFromRaw());

for (Feature feature : geoJsonSource.querySourceFeatures(null)) {
    Log.d(TAG, "onMapReady: " + feature.toJson());
}

但它始终返回Feature

的空列表

有谁知道如何从GeoJsonSource获取所有功能?

我的GeoJson文件是这样的:

{   "type": "FeatureCollection",   "features": [
    {
      "type": "Feature",
      "properties": {
        "edge_id": 1,
        "detailed": "no",
        "distance": 3106,
        "type": "normal"
      },
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            6.579816,
            46.72714
          ],
          [
            6.580883,
            46.728004
          ],
          [
            6.582048,
            46.728982
          ],
          [
            6.583276,
            46.730096
          ],
          [
            6.584309,
            46.731073
          ],
          [
            6.58524,
            46.73232
          ],
          [
            6.586203,
            46.733657
          ],
          [
            6.5871,
            46.734926
          ],
          [
            6.58787,
            46.735991
          ],
          [
            6.588547,
            46.73674
          ],
          [
            6.589222,
            46.737624
          ],
          [
            6.590613,
            46.738806
          ],
          [
            6.591552,
            46.739512
          ],
          [
            6.593013,
            46.740425
          ],
          [
            6.594249,
            46.74111
          ],
          [
            6.59627,
            46.741869
          ],
          [
            6.599075,
            46.742814
          ],
          [
            6.599074,
            46.742836
          ],
          [
            6.601293,
            46.743506
          ],
          [
            6.60276,
            46.744081
          ],
          [
            6.604356,
            46.744768
          ],
          [
            6.60556,
            46.745363
          ],
          [
            6.607537,
            46.746509
          ]
        ]
      }
    },
    ...   ] }

1 个答案:

答案 0 :(得分:0)

您可以使用以下方法查询源中的所有功能: source.querySourceFeatures(Expression.all())