Closed X-SLAYER closed 4 years ago
One way to read and port remote GeoJSON data
var url = 'https://geomatics.vn/test/new.geojson';
http.get(url).then((response) {
if (response.statusCode == 200) {
var jsonResponse = convert.jsonDecode(response.body);
//print(jsonResponse);
var geoJSON = GeoJSON.create('');
String type = jsonResponse['type'];
switch (type) {
case 'FeatureCollection':
var features = jsonResponse['features'];
for (var item in features) {
geoJSON.featureCollection.features
.add(GeoJSONFeature.fromMap(item));
}
break;
default:
}
print(geoJSON.featureCollection.toMap);
} else {
print('Request failed with status: ${response.statusCode}.');
}
});
thnx works fine but is there any way to clear path? because if i used the same path name he will get the old featureCollection too
thnx works fine but is there any way to clear path? because if i used the same path name he will get the old featureCollection too
Each GeoJSON object has a path parameter, which can be used to save as a file or to identify a GeoJSON object. We cached the GeoJSON object using path identifiers.
is there a way to read GeoJSON file directly from remote url ?