31 lines
801 B
Dart
31 lines
801 B
Dart
|
|
|
|
import 'package:geojson/geojson.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:rogapp/services/location_service.dart';
|
|
|
|
class HomeController extends GetxController {
|
|
|
|
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
|
|
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
LocationService.loadLocations().then((value){
|
|
locations.add(value!);
|
|
});
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} |