我想从一个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
]
]
}
},
... ] }