diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 592a2ce..df78b3b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -31,5 +31,7 @@ + diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 4b322f3..1d34060 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -7,6 +7,14 @@ PODS: - FMDB/standard (2.7.5) - geolocator_apple (1.2.0): - Flutter + - google_maps_flutter (0.0.1): + - Flutter + - GoogleMaps + - GoogleMaps (4.1.0): + - GoogleMaps/Maps (= 4.1.0) + - GoogleMaps/Base (4.1.0) + - GoogleMaps/Maps (4.1.0): + - GoogleMaps/Base - image_picker (0.0.1): - Flutter - path_provider_ios (0.0.1): @@ -23,6 +31,7 @@ DEPENDENCIES: - Flutter (from `Flutter`) - flutter_compass (from `.symlinks/plugins/flutter_compass/ios`) - geolocator_apple (from `.symlinks/plugins/geolocator_apple/ios`) + - google_maps_flutter (from `.symlinks/plugins/google_maps_flutter/ios`) - image_picker (from `.symlinks/plugins/image_picker/ios`) - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) - permission_handler (from `.symlinks/plugins/permission_handler/ios`) @@ -32,6 +41,7 @@ DEPENDENCIES: SPEC REPOS: trunk: - FMDB + - GoogleMaps EXTERNAL SOURCES: Flutter: @@ -40,6 +50,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_compass/ios" geolocator_apple: :path: ".symlinks/plugins/geolocator_apple/ios" + google_maps_flutter: + :path: ".symlinks/plugins/google_maps_flutter/ios" image_picker: :path: ".symlinks/plugins/image_picker/ios" path_provider_ios: @@ -56,6 +68,8 @@ SPEC CHECKSUMS: flutter_compass: cbbd285cea1584c7ac9c4e0c3e1f17cbea55e855 FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401 + google_maps_flutter: c59fc576c0d0c7f4dc4bd63832c862d22d5a7c6d + GoogleMaps: 008e2c80e38605b56b560e8deb73d4194ff30bef image_picker: 541dcbb3b9cf32d87eacbd957845d8651d6c62c3 path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 5acdf5c..624c1c2 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -140,6 +140,7 @@ 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 8340085CA329EF510409EEF4 /* [CP] Embed Pods Frameworks */, + 98C3810C530EA7CF0B7CC3E0 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -265,6 +266,23 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; + 98C3810C530EA7CF0B7CC3E0 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index 3763683..6f55dc6 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -1,5 +1,6 @@ import UIKit import Flutter +import GoogleMaps @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { @@ -7,6 +8,7 @@ import Flutter _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + GMSServices.provideAPIKey("AIzaSyBLgnwft3py6c4YkT-MxZ9y4zYGFgAEmRk") GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 3a32b4a..f595daf 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + io.flutter.embedded_views_preview + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName diff --git a/lib/pages/destination/destination_controller.dart b/lib/pages/destination/destination_controller.dart index a25327c..1f6718b 100644 --- a/lib/pages/destination/destination_controller.dart +++ b/lib/pages/destination/destination_controller.dart @@ -5,11 +5,13 @@ import 'package:get/get.dart'; import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/services/destination_service.dart'; +import 'package:rogapp/services/maxtrix_service.dart'; class DestinationController extends GetxController { List destinations = [].obs; + Map matrix = {}; final IndexController indexController = Get.find(); @@ -24,8 +26,16 @@ class DestinationController extends GetxController { int user_id = indexController.currentUser[0]["user"]["id"] as int; //print(user_id); DestinationService.getDestinations(user_id).then((value){ - destinations.clear(); - destinations = value; + + MatrixService.getDestinations(value).then((mat){ + print(mat); + matrix = mat; + + destinations.clear(); + destinations = value; + + }); + //var val = value[2]["location"]["id"]; //print("-----current destinations ----- ${val}"); }); diff --git a/lib/pages/destination/destination_page.dart b/lib/pages/destination/destination_page.dart index 35fe570..f32b922 100644 --- a/lib/pages/destination/destination_page.dart +++ b/lib/pages/destination/destination_page.dart @@ -110,8 +110,8 @@ class _DestinationPageState extends State { startChild: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text("12:30"), - Text("01:20"), + Text(destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString()), + Text(destinationController.matrix["rows"][0]["elements"][index]["duration"]["text"].toString()) ], ), ); diff --git a/lib/pages/index/index_controller.dart b/lib/pages/index/index_controller.dart index 4a9b70c..4116660 100644 --- a/lib/pages/index/index_controller.dart +++ b/lib/pages/index/index_controller.dart @@ -1,5 +1,8 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_map/flutter_map.dart'; +import 'package:flutter_map/plugin_api.dart'; import 'package:geojson/geojson.dart'; import 'package:get/get.dart'; import 'package:latlong2/latlong.dart'; @@ -22,7 +25,6 @@ class IndexController extends GetxController { List> currentUser = >[].obs; List currentAction = [].obs; - var is_loading = false.obs; @@ -47,20 +49,19 @@ class IndexController extends GetxController { void onInit() { super.onInit(); - if(locations.length == 0){ - LocationService.loadLocations().then((value){ - locations.add(value!); - //print(value); - }); - } + // 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"); }); - } - loadCats(); - + } + //loadCats(); } void login(String email, String password, BuildContext context){ @@ -112,25 +113,51 @@ class IndexController extends GetxController { } - void loadCats(){ + // void loadCats(){ + // dynamic initVal = {'category':'---'}; + // CatService.loadCats().then((value) { + // //value!.add(initVal); + // print("###########"); + // print(value); + // cats.add(value); + // }); + // } + + + + void loadCatsv2(){ dynamic initVal = {'category':'---'}; - CatService.loadCats().then((value) { - //value!.add(initVal); - print("###########"); - print(value); - cats.add(value); - }); + LatLngBounds bounds = mapController!.bounds!; + if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){ + cats.clear(); + CatService.loadCats(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude).then((value) { + print("###########"); + print(value); + cats.add(value); + }); + } } + + void refreshLocationForCat(){ - if(subDropdownValue == "-1"){ - LocationService.loadLocationsFor(dropdownValue, currentCat[0]); - print("loading main------"); - } - else{ - LocationService.loadLocationsSubFor(subDropdownValue, currentCat[0]); - print("loading sub------"); - } + loadLocationsBound(); + // if(subDropdownValue == "-1"){ + // LocationService.loadLocationsFor(dropdownValue, currentCat[0]).then((value){ + // locations.clear(); + // locations.add(value!); + // is_loading.value = false; + // }); + // print("loading main------"); + // } + // else{ + // LocationService.loadLocationsSubFor(subDropdownValue, currentCat[0]).then((value){ + // locations.clear(); + // locations.add(value!); + // is_loading.value = false; + // }); + // print("loading sub------"); + // } } void loadSubPerfFor(String perf){ @@ -158,18 +185,48 @@ class IndexController extends GetxController { } void loadLocationforPerf(String perf, MapController mapController) async { + String cat = currentCat.isNotEmpty == true ? currentCat[0] : ""; + print(currentCat); + // LocationService.loadLocationsFor(perf, cat).then((value){ + // locations.clear(); + // locations.add(value!); + // mapController.fitBounds(currentBound[0]); + // }); locations.clear(); - LocationService.loadLocationsFor(perf, currentCat[0]).then((value){ + mapController.fitBounds(currentBound[0]); + } + + void loadLocationforSubPerf(String subperf, MapController mapController) async { + String cat = currentCat.isNotEmpty == true ? currentCat[0] : ""; + print(currentCat); + LocationService.loadLocationsSubFor(subperf, cat).then((value){ + locations.clear(); locations.add(value!); - mapController.fitBounds(currentBound[0]); }); } - void loadLocationforSubPerf(String subperf, MapController mapController) async { - locations.clear(); - LocationService.loadLocationsSubFor(subperf, currentCat[0]).then((value){ - locations.add(value!); - }); + void loadLocationsBound(){ + String cat = currentCat.isNotEmpty ? currentCat[0] : ""; + LatLngBounds bounds = mapController!.bounds!; + print(currentCat); + if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){ + LocationService.loadLocationsBound(bounds.southWest!.latitude, bounds.southWest!.longitude, bounds.northWest.latitude, bounds.northWest.longitude, bounds.northEast!.latitude, bounds.northEast!.longitude, bounds.southEast.latitude, bounds.southEast.longitude, cat).then((value){ + print("---value length ------ ${value!.collection.length}"); + if(value == null){ + return; + } + if(value != null && value.collection.isEmpty){ + Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",)); + } + if(value != null && value.collection.isNotEmpty){ + print("---- added---"); + locations.clear(); + locations.add(value); + loadCatsv2(); + } + }); + } + } void setBound(LatLngBounds bounds){ @@ -206,12 +263,14 @@ class IndexController extends GetxController { loadSubPerfFor(perf); loadLocationforPerf(perf, mapController); zoomtoMainPerf(perf); + is_loading.value = false; } void populateForSubPerf(String subperf, MapController mapController){ subDropdownValue = subperf; loadLocationforSubPerf(subperf, mapController); zoomtoSubPerf(subperf); + is_loading.value = false; } diff --git a/lib/pages/index/index_page.dart b/lib/pages/index/index_page.dart index 040ae7c..883035a 100644 --- a/lib/pages/index/index_page.dart +++ b/lib/pages/index/index_page.dart @@ -5,6 +5,7 @@ import 'package:get/get.dart'; import 'package:rogapp/pages/drawer/drawer_page.dart'; import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/routes/app_pages.dart'; +import 'package:rogapp/services/maxtrix_service.dart'; import 'package:rogapp/widgets/bread_crum_widget.dart'; import 'package:rogapp/widgets/cat_widget.dart'; import 'package:rogapp/widgets/list_widget.dart'; @@ -72,7 +73,20 @@ class IndexPage extends GetView { BreadCrumbWidget(), Container(width: 24.0,), Obx(()=> - indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text("") + Row( + children: [ + indexController.currentCat.isNotEmpty ? Text(indexController.currentCat[0].toString()): Text(""), + indexController.currentCat.isNotEmpty ? + IconButton( + onPressed: (){ + indexController.currentCat.clear(); + indexController.loadLocationsBound(); + }, + icon: Icon(Icons.cancel, color: Colors.red,) + ) : + Container(width: 0, height: 0,) + ], + ) ), ], ), diff --git a/lib/pages/loading/loading_page.dart b/lib/pages/loading/loading_page.dart new file mode 100644 index 0000000..dd6f82c --- /dev/null +++ b/lib/pages/loading/loading_page.dart @@ -0,0 +1,16 @@ +import 'package:flutter/material.dart'; + +class LoadingPage extends StatelessWidget { + const LoadingPage({ Key? key }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + alignment: Alignment.topCenter, + margin: EdgeInsets.only(top: 20), + child: CircularProgressIndicator( + value: 0.8, + ) + ); + } +} \ No newline at end of file diff --git a/lib/routes/app_pages.dart b/lib/routes/app_pages.dart index 9b17c6b..22bb17c 100644 --- a/lib/routes/app_pages.dart +++ b/lib/routes/app_pages.dart @@ -4,6 +4,7 @@ import 'package:rogapp/pages/destination/destination_page.dart'; import 'package:rogapp/pages/index/index_binding.dart'; import 'package:rogapp/pages/index/index_page.dart'; import 'package:rogapp/pages/landing/landing_page.dart'; +import 'package:rogapp/pages/loading/loading_page.dart'; import 'package:rogapp/pages/login/login_page.dart'; import 'package:rogapp/pages/register/register_page.dart'; import 'package:rogapp/spa/spa_binding.dart'; @@ -21,6 +22,7 @@ class AppPages { static const LOGIN = Routes.LOGIN; static const REGISTER = Routes.REGISTER; static const TRAVEL = Routes.TRAVEL; + static const LOADING = Routes.LOADING; static final routes = [ // GetPage( @@ -62,6 +64,11 @@ class AppPages { name: Routes.TRAVEL, page: () => DestinationPage(), binding: DestinationBinding(), + ), + GetPage( + name: Routes.LOADING, + page: () => LoadingPage(), + //binding: DestinationBinding(), ) ]; } \ No newline at end of file diff --git a/lib/routes/app_routes.dart b/lib/routes/app_routes.dart index 5d30d0e..5d1985c 100644 --- a/lib/routes/app_routes.dart +++ b/lib/routes/app_routes.dart @@ -12,4 +12,5 @@ abstract class Routes { static const LOGIN = '/login'; static const REGISTER = '/register'; static const TRAVEL = '/travel'; + static const LOADING = '/loading'; } diff --git a/lib/services/action_service.dart b/lib/services/action_service.dart index 86c941b..2c01098 100644 --- a/lib/services/action_service.dart +++ b/lib/services/action_service.dart @@ -6,7 +6,7 @@ class ActionService{ static Future> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async { Map cats = {}; - String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}"; + String url = "http://container.intranet.sumasen.net:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}"; final http.Response response = await http.get( Uri.parse(url), headers: { @@ -23,7 +23,7 @@ class ActionService{ static Future?> userAction(int user_id, int location_id) async { List cats = []; - String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}'; + String url = 'http://container.intranet.sumasen.net:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/services/auth_service.dart b/lib/services/auth_service.dart index 4eb3727..aa91db3 100644 --- a/lib/services/auth_service.dart +++ b/lib/services/auth_service.dart @@ -6,7 +6,7 @@ class AuthService{ static Future> login(String email, String password) async { Map cats = {}; - String url = 'http://localhost:8100/api/login/'; + String url = 'http://container.intranet.sumasen.net:8100/api/login/'; final http.Response response = await http.post( Uri.parse(url), headers: { @@ -27,7 +27,7 @@ class AuthService{ static Future> register(String email, String password) async { Map cats = {}; - String url = 'http://localhost:8100/api/register/'; + String url = 'http://container.intranet.sumasen.net:8100/api/register/'; final http.Response response = await http.post( Uri.parse(url), headers: { diff --git a/lib/services/cat_service.dart b/lib/services/cat_service.dart index 8be7fb0..9119aa2 100644 --- a/lib/services/cat_service.dart +++ b/lib/services/cat_service.dart @@ -5,9 +5,12 @@ import 'package:http/http.dart' as http; class CatService{ - static Future?> loadCats() async { + static Future?> loadCats(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4) async { List cats = []; - String url = 'http://localhost:8100/api/cats/'; + String url = 'http://container.intranet.sumasen.net:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; + + //String url = 'http://container.intranet.sumasen.net:8100/api/cats/'; + print("---- cat url is ${url}"); final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -26,3 +29,7 @@ class CatService{ } + + + + diff --git a/lib/services/destination_service.dart b/lib/services/destination_service.dart index b0ec255..239aff8 100644 --- a/lib/services/destination_service.dart +++ b/lib/services/destination_service.dart @@ -6,7 +6,7 @@ class DestinationService{ static Future> getDestinations(int user_id) async { List cats = []; - String url = "http://localhost:8100/api/destinations/?user_id=${user_id}"; + String url = "http://container.intranet.sumasen.net:8100/api/destinations/?user_id=${user_id}"; final http.Response response = await http.get( Uri.parse(url), headers: { @@ -22,7 +22,7 @@ class DestinationService{ static Future updateOrder(int action_id, int order, String dir) async { int cats = 0; - String url = "http://localhost:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}"; + String url = "http://container.intranet.sumasen.net:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}"; final http.Response response = await http.get( Uri.parse(url), headers: { diff --git a/lib/services/location_line_service.dart b/lib/services/location_line_service.dart index 68309cb..a5adc70 100644 --- a/lib/services/location_line_service.dart +++ b/lib/services/location_line_service.dart @@ -7,7 +7,7 @@ class LocationLineService{ final geo = GeoJson(); GeoJsonFeature? fs; - String url = 'http://localhost:8100/api/location_line/'; + String url = 'http://container.intranet.sumasen.net:8100/api/location_line/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/services/location_polygon_service.dart b/lib/services/location_polygon_service.dart index 59e4d56..cf4b03d 100644 --- a/lib/services/location_polygon_service.dart +++ b/lib/services/location_polygon_service.dart @@ -7,7 +7,7 @@ class LocationPolygonervice{ final geo = GeoJson(); GeoJsonFeature? fs; - String url = 'http://localhost:8100/api/location_polygon/'; + String url = 'http://container.intranet.sumasen.net:8100/api/location_polygon/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/services/location_service.dart b/lib/services/location_service.dart index 3114d18..d63a782 100644 --- a/lib/services/location_service.dart +++ b/lib/services/location_service.dart @@ -6,7 +6,7 @@ import 'package:http/http.dart' as http; class LocationService{ static Future loadLocations() async { - String url = 'http://localhost:8100/api/location/'; + String url = 'http://container.intranet.sumasen.net:8100/api/location/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -23,11 +23,12 @@ class LocationService{ static Future loadLocationsFor(String perfecture, String cat) async { String url = ""; if(cat.isNotEmpty){ - url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; + url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; } else{ - url = 'http://localhost:8100/api/inperf/?perf=' + perfecture; + url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture; } + //print("----- url ---- ${url} --- ${cat}"); //String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat; final response = await http.get(Uri.parse(url), headers: { @@ -47,10 +48,11 @@ class LocationService{ static Future loadLocationsSubFor(String subperfecture, String cat) async { String url = ""; if(cat.isNotEmpty){ - url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat; + url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat; } else{ - url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture; + print("------ loading location in sub----"); + url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture; } final response = await http.get(Uri.parse(url), headers: { @@ -67,5 +69,38 @@ class LocationService{ } + static Future loadLocationsBound(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4, String cat) async { + String url = ""; + print("cat is ----- ${cat}"); + if(cat.isNotEmpty){ + url = 'http://container.intranet.sumasen.net:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat; + } + else{ + url = 'http://container.intranet.sumasen.net:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}'; + } + print("----url --- ${url}"); + final response = await http.get(Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + }, + ); + + if (response.statusCode == 500) { + return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes)); + } + + if (response.statusCode == 200) { + GeoJsonFeatureCollection cc = await featuresFromGeoJson(utf8.decode(response.bodyBytes)); + if(cc.collection.isEmpty){ + return null; + } + else{ + return cc; + } + } + return null; + } + + } \ No newline at end of file diff --git a/lib/services/maxtrix_service.dart b/lib/services/maxtrix_service.dart new file mode 100644 index 0000000..dc5842c --- /dev/null +++ b/lib/services/maxtrix_service.dart @@ -0,0 +1,44 @@ + +import 'dart:convert'; +import 'package:http/http.dart' as http; + + +class MatrixService{ + + static Future> getDestinations(List destinations) async { + + String locs = ""; + String origin = ""; + int i = 0; + for(Map loc in destinations){ + + if(i==0){ + origin = "${loc["location"]["geometry"]["coordinates"][0][1]}, ${loc["location"]["geometry"]["coordinates"][0][0]}"; + } + + print("lat is ${loc["location"]["geometry"]["coordinates"][0][1]}, long is ${loc["location"]["geometry"]["coordinates"][0][0]}"); + locs += "${loc["location"]["geometry"]["coordinates"][0][1]}, ${loc["location"]["geometry"]["coordinates"][0][0]}|"; + i++; + } + + //print(locs); + + Map cats = {}; + String url = "https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${locs}&origins=${origin}&key=AIzaSyBLgnwft3py6c4YkT-MxZ9y4zYGFgAEmRk"; + print(url); + final http.Response response = await http.get( + Uri.parse(url), + headers: { + 'Content-Type': 'application/json; charset=UTF-8', + } + ); + + if (response.statusCode == 200) { + cats = json.decode(utf8.decode(response.bodyBytes)); + } + return cats; + } + + +} + diff --git a/lib/services/perfecture_service.dart b/lib/services/perfecture_service.dart index ceefdd5..635ddcf 100644 --- a/lib/services/perfecture_service.dart +++ b/lib/services/perfecture_service.dart @@ -6,7 +6,7 @@ class PerfectureService{ static Future?> loadPerfectures() async { List perfs = []; - String url = 'http://localhost:8100/api/perf_main/'; + String url = 'http://container.intranet.sumasen.net:8100/api/perf_main/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -22,7 +22,7 @@ class PerfectureService{ static Future?> loadSubPerfectures(String sub) async { List perfs = []; - String url = 'http://localhost:8100/api/subperfinmain/?perf=' + sub; + String url = 'http://container.intranet.sumasen.net:8100/api/subperfinmain/?perf=' + sub; //String url = 'http://container.intranet.sumasen.net:8100/api/insubperf/?perf=' + sub; final response = await http.get(Uri.parse(url), headers: { @@ -40,7 +40,7 @@ class PerfectureService{ static Future?> getMainPerfExt(String id) async { List perfs = []; - String url = 'http://localhost:8100/api/mainperfext/?perf=' + id; + String url = 'http://container.intranet.sumasen.net:8100/api/mainperfext/?perf=' + id; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', @@ -57,7 +57,7 @@ class PerfectureService{ static Future?> getSubExt(String id) async { List perfs = []; - String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id; + String url = 'http://container.intranet.sumasen.net:8100/api/perfext/?sub_perf=' + id; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', diff --git a/lib/widgets/cat_widget.dart b/lib/widgets/cat_widget.dart index 9fea7da..b96a1ed 100644 --- a/lib/widgets/cat_widget.dart +++ b/lib/widgets/cat_widget.dart @@ -24,6 +24,7 @@ class _CatWidgetState extends State { widget.indexController.refreshLocationForCat(); setState(() { print(value); + //widget.indexController.is_loading.value = true; defaultValue = value.toString(); }); }, diff --git a/lib/widgets/map_widget.dart b/lib/widgets/map_widget.dart index e53c303..808fab6 100644 --- a/lib/widgets/map_widget.dart +++ b/lib/widgets/map_widget.dart @@ -1,3 +1,6 @@ +import 'dart:async'; +import 'dart:ffi'; + import 'package:flutter/material.dart'; import 'package:flutter_map/plugin_api.dart'; import 'package:flutter_map_location_marker/flutter_map_location_marker.dart'; @@ -16,16 +19,38 @@ class MapWidget extends StatelessWidget { MapWidget({ Key? key}) : super(key: key); + StreamSubscription? subscription; + @override Widget build(BuildContext context) { final PopupController _popupController = PopupController(); return Stack( children: [ Obx(() => + indexController.is_loading == true ? Padding( + padding: const EdgeInsets.only(top: 60.0), + child: CircularProgressIndicator(), + ): FlutterMap( //mapController: mapController, options: MapOptions( - onMapCreated: (c){indexController.mapController = c;}, + onMapCreated: (c){ + indexController.mapController = c; + + indexController.mapController!.onReady.then((_) { + subscription = indexController.mapController!.mapEventStream.listen((MapEvent mapEvent) { + if (mapEvent is MapEventMoveStart) { + //print(DateTime.now().toString() + ' [MapEventMoveStart] START'); + // do something + } + if (mapEvent is MapEventMoveEnd) { + //print(DateTime.now().toString() + ' [MapEventMoveStart] END'); + indexController.loadLocationsBound(); + } + }); + }); + + }, //center: LatLng(37.15319600454702, 139.58765950528198), bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]), zoom: 1, @@ -34,20 +59,75 @@ class MapWidget extends StatelessWidget { plugins: [ MarkerClusterPlugin(), ], + + onPositionChanged: (MapPosition pos, isvalue){ + + // LatLng c1 = pos.center?? LatLng(0, 0); + + // Timer(Duration(milliseconds:800), () { + // print(pos.bounds!.center); + // print("Yeah, this line is printed after 3 second"); + // LatLng c2 = pos.center?? LatLng(0, 0); + // if(c1.latitude != 0 && c1.latitude == c2.latitude){ + // print("------ calling ----"); + // //indexController.loadLocationsBound(); + // } + + // }); + + // + }, onTap: (_, __) => _popupController .hideAllPopups(), // Hide popup when the map is tapped. ), + layers: [ + // MarkerLayerOptions( + // markers: indexController.locations[0].collection.map((i) { + // print("i si ${i.properties!['location_id']}"); + // GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint; + // print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}"); + // return Marker( + // anchorPos: AnchorPos.align(AnchorAlign.center), + // height: 70.0, + // width: 70.0, + // point: LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude), + // builder: (ctx) => + // IconButton( + // icon: const Icon(Icons.pin_drop), + // tooltip: 'Increase volume by 10', + // onPressed: () { + // GeoJsonFeature? fs = indexController.getFeatureForLatLong(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude); + // print(fs); + // if(fs != null){ + // if(indexController.currentFeature.length > 0) { + // indexController.currentFeature.clear(); + // } + // indexController.currentFeature.add(fs); + // indexController.getAction(); + + // showModalBottomSheet(context: context, isScrollControlled: true, + // builder:((context) => BottomSheetWidget()) + // ); + // } + // }, + // ), + + // ); + // }).toList(), + // ), + ], children: [ BaseLayer(), LocationMarkerLayerWidget(), + indexController.locations.length > 0 ? MarkerClusterLayerWidget( options: MarkerClusterLayerOptions( - spiderfyCircleRadius: 80, + spiderfyCircleRadius: 0, spiderfySpiralDistanceMultiplier: 2, circleSpiralSwitchover: 12, - maxClusterRadius: 20, + maxClusterRadius: 0, rotate: true, onMarkerTap: (marker){ GeoJsonFeature? fs = indexController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude); diff --git a/lib/widgets/perfecture_widget.dart b/lib/widgets/perfecture_widget.dart index 74f8d1e..6906173 100644 --- a/lib/widgets/perfecture_widget.dart +++ b/lib/widgets/perfecture_widget.dart @@ -69,6 +69,7 @@ class _PerfectureWidgetState extends State { onChanged: (String? newValue) { //setState(() { if(newValue != null){ + widget.indexController.is_loading.value = true; widget.indexController.dropdownValue = newValue; widget.indexController.populateForPerf(newValue, widget.mapController); } @@ -92,6 +93,7 @@ class _PerfectureWidgetState extends State { onChanged: (String? newValue) { setState(() { if(newValue != null){ + widget.indexController.is_loading.value = true; widget.indexController.populateForSubPerf(newValue, widget.mapController); //widget.indexController.loadLocationforSubPerf(newValue, widget.mapController); //widget.indexController.subDropdownValue = newValue; diff --git a/pubspec.lock b/pubspec.lock index ff33a18..72dd546 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -167,6 +167,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + flutter_polyline_points: + dependency: "direct main" + description: + name: flutter_polyline_points + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" flutter_test: dependency: "direct dev" description: flutter @@ -261,6 +268,27 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.3.1" + google_maps_flutter: + dependency: "direct main" + description: + name: google_maps_flutter + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + google_maps_flutter_platform_interface: + dependency: transitive + description: + name: google_maps_flutter_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.5" + google_maps_webservice: + dependency: "direct main" + description: + name: google_maps_webservice + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.19" http: dependency: transitive description: @@ -546,6 +574,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + stream_transform: + dependency: transitive + description: + name: stream_transform + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" string_scanner: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 68d31e8..e433fc8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -61,6 +61,9 @@ dependencies: url_launcher: ^6.0.20 flutter_breadcrumb: ^1.0.1 timeline_tile: ^2.0.0 + google_maps_flutter: ^2.1.5 + flutter_polyline_points: ^1.0.0 + google_maps_webservice: ^0.0.19 dev_dependencies: