发布于 2020-12-12 10:40:44
List<LatLng> latLngListFromDatabase = new ArrayList<>();
List<Feature> featureList = new ArrayList<>();
for (LatLng latLngObject : latLngListFromDatabase) {
featureList.add(Feature.fromGeometry(Point.fromLngLat(latLngObject.getLongitude(), latLngObject.getLatitude())));
}
loadedMapStyle.addSource(new GeoJsonSource("source-id", FeatureCollection.fromFeatures(featureList)));发布于 2020-12-12 10:39:25
若要将LatLng对象转换为功能,请使用:
var feature = Feature.fromGeometry(Point.fromLngLat(longitude, latitude))并将它们添加到featureList中。然后,您可以使用以下方法创建FeatureCollection实例:
public static FeatureCollection fromFeatures(@NonNull List<Feature> features)
最后,在GeoJsonSource中有一个构造函数,您可以在其中使用FeatureCollection而不是URI:
public GeoJsonSource(String id, FeatureCollection features, GeoJsonOptions options)https://stackoverflow.com/questions/65156940
复制相似问题