Files
rog_app/lib/services/location_service.dart
Mohamed Nouffer ee3845681d update
2022-03-30 16:19:18 +05:30

42 lines
1.2 KiB
Dart

import 'dart:convert';
import 'package:geojson/geojson.dart';
import 'package:http/http.dart' as http;
class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocations() async {
final geo = GeoJson();
GeoJsonFeatureCollection? fs;
String url = 'http://localhost:8100/api/location/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
return featuresFromGeoJson(utf8.decode(response.bodyBytes));
}
}
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture) async {
final geo = GeoJson();
GeoJsonFeatureCollection? fs;
String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
GeoJsonFeatureCollection cc = await featuresFromGeoJson(utf8.decode(response.bodyBytes));
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
}
}
}