// import 'package:flutter_map/plugin_api.dart'; // import 'package:geojson/geojson.dart'; // import 'package:get/get.dart'; // import 'package:latlong2/latlong.dart'; // import 'package:meta/meta.dart'; // import 'package:rogapp/pages/map/map_page.dart'; // import 'package:rogapp/services/location_service.dart'; // import 'package:rogapp/services/perfecture_service.dart'; // class HomeController extends GetxController { // List locations = [].obs; // List currentFeature = [].obs; // List perfectures = [].obs; // List currentBound = [].obs; // List subPerfs = [].obs; // String SubDropdownValue = "-1"; // @override // void onInit() { // super.onInit(); // if(locations.length == 0){ // LocationService.loadLocations().then((value){ // locations.add(value!); // //print(value); // }); // } // if(perfectures.length == 0){ // PerfectureService.loadPerfectures().then((value){ // perfectures.add(value); // loadSubPerfFor("9"); // }); // } // } // void getBoundFromLatLng(List list) { // double? x0, x1, y0, y1; // for (LatLng latLng in list) { // if (x0 == null) { // x0 = x1 = latLng.latitude; // y0 = y1 = latLng.longitude; // } else { // if (latLng.latitude > x1!) x1 = latLng.latitude; // if (latLng.latitude < x0) x0 = latLng.latitude; // if (latLng.longitude > y1!) y1 = latLng.longitude; // if (latLng.longitude < y0!) y0 = latLng.longitude; // } // } // currentBound.clear(); // if(x0 != null && x1 != null && y0 != null && y1 != null ){ // currentBound.add(LatLngBounds(LatLng(x1, y1), LatLng(x0, y0))); // } // } // void setBounds(){ // List lts = []; // if(locations.length > 0){ // for(GeoJsonFeature i in locations[0].collection){ // GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint; // LatLng lt = LatLng(p.geoSerie!.geoPoints[0].latitude , p.geoSerie!.geoPoints[0].longitude) ; // lts.add(lt); // } // } // else{ // LatLng lt = LatLng(37.15319600454702, 139.58765950528198); // lts.add(lt); // } // getBoundFromLatLng(lts); // } // void zoomtoMainPerf(String id, MapController mapController){ // PerfectureService.getMainPerfExt(id).then((value){ // print(value); // LatLng lat1 = LatLng(value![1], value[0]); // LatLng lat2 = LatLng(value[3], value[2]); // LatLngBounds bound = LatLngBounds(lat1, lat2); // mapController.fitBounds(bound); // }); // } // void zoomtoSubPerf(String id, MapController mapController){ // PerfectureService.getSubExt(id).then((value){ // LatLng lat1 = LatLng(value![1], value[0]); // LatLng lat2 = LatLng(value[3], value[2]); // LatLngBounds bound = LatLngBounds(lat1, lat2); // mapController.fitBounds(bound); // }); // } // void loadLocationforPerf(String perf, MapController mapController) async { // locations.clear(); // LocationService.loadLocationsFor(perf).then((value){ // locations.add(value!); // setBounds(); // mapController.fitBounds(currentBound[0]); // }); // } // void loadLocationforSubPerf(String subperf, MapController mapController) async { // locations.clear(); // LocationService.loadLocationsSubFor(subperf).then((value){ // locations.add(value!); // //setBounds(); // //mapController!.fitBounds(currentBound[0]); // }); // } // void loadSubPerfFor(String perf){ // subPerfs.clear(); // dynamic initVal = {'id':'-1', 'adm2_ja':'----'}; // PerfectureService.loadSubPerfectures(perf).then((value){ // value!.add(initVal); // subPerfs.add(value); // SubDropdownValue = getSubInitialVal(); // //print(subPerfs[0]); // }); // } // String getSubInitialVal(){ // int min = 0; // if(subPerfs.length > 0){ // min = subPerfs[0][0]['id'] as int; // for(var sub in subPerfs[0]){ // int x = int.parse(sub['id'].toString()); // as int; // if(x < min){ // min = x; // } // } // } // return min.toString(); // } // GeoJsonFeature? getFeatureForLatLong(double lat, double long){ // if(locations.length > 0){ // for(GeoJsonFeature i in locations[0].collection){ // GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint; // if(p.geoSerie!.geoPoints[0].latitude == lat && p.geoSerie!.geoPoints[0].longitude == long){ // return i; // } // } // } // } // void makeNext(GeoJsonFeature fs){ // GeoJsonFeature pt = fs as GeoJsonFeature; // for(int i=0; i<= locations[0].collection.length - 1; i++){ // GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint; // if(p.geoSerie!.geoPoints[0].latitude == pt.geometry!.geoSerie!.geoPoints[0].latitude && p.geoSerie!.geoPoints[0].longitude == pt.geometry!.geoSerie!.geoPoints[0].longitude ){ // if(currentFeature.length > 0){ // currentFeature.clear(); // } // if(i >= locations[0].collection.length - 1 ){ // currentFeature.add(locations[0].collection[0] as GeoJsonFeature); // } // else{ // currentFeature.add(locations[0].collection[i + 1] as GeoJsonFeature); // } // } // } // } // void makePrevious(GeoJsonFeature fs){ // GeoJsonFeature pt = fs as GeoJsonFeature; // for(int i=0; i<= locations[0].collection.length - 1; i++){ // GeoJsonMultiPoint p = locations[0].collection[i].geometry as GeoJsonMultiPoint; // if(p.geoSerie!.geoPoints[0].latitude == pt.geometry!.geoSerie!.geoPoints[0].latitude && p.geoSerie!.geoPoints[0].longitude == pt.geometry!.geoSerie!.geoPoints[0].longitude ){ // if(currentFeature.length > 0){ // currentFeature.clear(); // } // if(i == 0 ){ // currentFeature.add(locations[0].collection[locations[0].collection.length -1] as GeoJsonFeature); // } // else{ // currentFeature.add(locations[0].collection[i - 1] as GeoJsonFeature); // } // } // } // } // }