This commit is contained in:
Mohamed Nouffer
2022-05-18 19:09:26 +05:30
parent 80a976baa0
commit ee0440e6b6
26 changed files with 411 additions and 59 deletions

View File

@ -31,5 +31,7 @@
<meta-data <meta-data
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
<meta-data android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyBLgnwft3py6c4YkT-MxZ9y4zYGFgAEmRk"/>
</application> </application>
</manifest> </manifest>

View File

@ -7,6 +7,14 @@ PODS:
- FMDB/standard (2.7.5) - FMDB/standard (2.7.5)
- geolocator_apple (1.2.0): - geolocator_apple (1.2.0):
- Flutter - 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): - image_picker (0.0.1):
- Flutter - Flutter
- path_provider_ios (0.0.1): - path_provider_ios (0.0.1):
@ -23,6 +31,7 @@ DEPENDENCIES:
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- flutter_compass (from `.symlinks/plugins/flutter_compass/ios`) - flutter_compass (from `.symlinks/plugins/flutter_compass/ios`)
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/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`) - image_picker (from `.symlinks/plugins/image_picker/ios`)
- path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`) - permission_handler (from `.symlinks/plugins/permission_handler/ios`)
@ -32,6 +41,7 @@ DEPENDENCIES:
SPEC REPOS: SPEC REPOS:
trunk: trunk:
- FMDB - FMDB
- GoogleMaps
EXTERNAL SOURCES: EXTERNAL SOURCES:
Flutter: Flutter:
@ -40,6 +50,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_compass/ios" :path: ".symlinks/plugins/flutter_compass/ios"
geolocator_apple: geolocator_apple:
:path: ".symlinks/plugins/geolocator_apple/ios" :path: ".symlinks/plugins/geolocator_apple/ios"
google_maps_flutter:
:path: ".symlinks/plugins/google_maps_flutter/ios"
image_picker: image_picker:
:path: ".symlinks/plugins/image_picker/ios" :path: ".symlinks/plugins/image_picker/ios"
path_provider_ios: path_provider_ios:
@ -56,6 +68,8 @@ SPEC CHECKSUMS:
flutter_compass: cbbd285cea1584c7ac9c4e0c3e1f17cbea55e855 flutter_compass: cbbd285cea1584c7ac9c4e0c3e1f17cbea55e855
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401 geolocator_apple: cc556e6844d508c95df1e87e3ea6fa4e58c50401
google_maps_flutter: c59fc576c0d0c7f4dc4bd63832c862d22d5a7c6d
GoogleMaps: 008e2c80e38605b56b560e8deb73d4194ff30bef
image_picker: 541dcbb3b9cf32d87eacbd957845d8651d6c62c3 image_picker: 541dcbb3b9cf32d87eacbd957845d8651d6c62c3
path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0 permission_handler: ccb20a9fad0ee9b1314a52b70b76b473c5f8dab0

View File

@ -140,6 +140,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */, 9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
8340085CA329EF510409EEF4 /* [CP] Embed Pods Frameworks */, 8340085CA329EF510409EEF4 /* [CP] Embed Pods Frameworks */,
98C3810C530EA7CF0B7CC3E0 /* [CP] Copy Pods Resources */,
); );
buildRules = ( buildRules = (
); );
@ -265,6 +266,23 @@
shellPath = /bin/sh; shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 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 */ /* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */

View File

@ -1,5 +1,6 @@
import UIKit import UIKit
import Flutter import Flutter
import GoogleMaps
@UIApplicationMain @UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate { @objc class AppDelegate: FlutterAppDelegate {
@ -7,6 +8,7 @@ import Flutter
_ application: UIApplication, _ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool { ) -> Bool {
GMSServices.provideAPIKey("AIzaSyBLgnwft3py6c4YkT-MxZ9y4zYGFgAEmRk")
GeneratedPluginRegistrant.register(with: self) GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions) return super.application(application, didFinishLaunchingWithOptions: launchOptions)
} }

View File

@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>io.flutter.embedded_views_preview</key>
<true/>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string> <string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>

View File

@ -5,11 +5,13 @@ import 'package:get/get.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.dart'; import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/services/destination_service.dart'; import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/services/maxtrix_service.dart';
class DestinationController extends GetxController { class DestinationController extends GetxController {
List<dynamic> destinations = <dynamic>[].obs; List<dynamic> destinations = <dynamic>[].obs;
Map<String, dynamic> matrix = {};
final IndexController indexController = Get.find<IndexController>(); final IndexController indexController = Get.find<IndexController>();
@ -24,8 +26,16 @@ class DestinationController extends GetxController {
int user_id = indexController.currentUser[0]["user"]["id"] as int; int user_id = indexController.currentUser[0]["user"]["id"] as int;
//print(user_id); //print(user_id);
DestinationService.getDestinations(user_id).then((value){ 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"]; //var val = value[2]["location"]["id"];
//print("-----current destinations ----- ${val}"); //print("-----current destinations ----- ${val}");
}); });

View File

@ -110,8 +110,8 @@ class _DestinationPageState extends State<DestinationPage> {
startChild: Column( startChild: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Text("12:30"), Text(destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString()),
Text("01:20"), Text(destinationController.matrix["rows"][0]["elements"][index]["duration"]["text"].toString())
], ],
), ),
); );

View File

@ -1,5 +1,8 @@
import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:geojson/geojson.dart'; import 'package:geojson/geojson.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:latlong2/latlong.dart'; import 'package:latlong2/latlong.dart';
@ -23,7 +26,6 @@ class IndexController extends GetxController {
List<Map<String, dynamic>> currentUser = <Map<String, dynamic>>[].obs; List<Map<String, dynamic>> currentUser = <Map<String, dynamic>>[].obs;
List<dynamic> currentAction = <dynamic>[].obs; List<dynamic> currentAction = <dynamic>[].obs;
var is_loading = false.obs; var is_loading = false.obs;
MapController? mapController; MapController? mapController;
@ -47,20 +49,19 @@ class IndexController extends GetxController {
void onInit() { void onInit() {
super.onInit(); super.onInit();
if(locations.length == 0){ // if(locations.length == 0){
LocationService.loadLocations().then((value){ // LocationService.loadLocations().then((value){
locations.add(value!); // locations.add(value!);
//print(value); // //print(value);
}); // });
} // }
if(perfectures.length == 0){ if(perfectures.length == 0){
PerfectureService.loadPerfectures().then((value){ PerfectureService.loadPerfectures().then((value){
perfectures.add(value); perfectures.add(value);
loadSubPerfFor("9"); loadSubPerfFor("9");
}); });
} }
loadCats(); //loadCats();
} }
void login(String email, String password, BuildContext context){ 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':'---'}; dynamic initVal = {'category':'---'};
CatService.loadCats().then((value) { LatLngBounds bounds = mapController!.bounds!;
//value!.add(initVal); if(bounds.southEast != null && bounds.southWest != null && bounds.northEast != null && bounds.southEast != null ){
print("###########"); cats.clear();
print(value); 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) {
cats.add(value); print("###########");
}); print(value);
cats.add(value);
});
}
} }
void refreshLocationForCat(){ void refreshLocationForCat(){
if(subDropdownValue == "-1"){ loadLocationsBound();
LocationService.loadLocationsFor(dropdownValue, currentCat[0]); // if(subDropdownValue == "-1"){
print("loading main------"); // LocationService.loadLocationsFor(dropdownValue, currentCat[0]).then((value){
} // locations.clear();
else{ // locations.add(value!);
LocationService.loadLocationsSubFor(subDropdownValue, currentCat[0]); // is_loading.value = false;
print("loading sub------"); // });
} // 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){ void loadSubPerfFor(String perf){
@ -158,18 +185,48 @@ class IndexController extends GetxController {
} }
void loadLocationforPerf(String perf, MapController mapController) async { 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(); 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!); locations.add(value!);
mapController.fitBounds(currentBound[0]);
}); });
} }
void loadLocationforSubPerf(String subperf, MapController mapController) async { void loadLocationsBound(){
locations.clear(); String cat = currentCat.isNotEmpty ? currentCat[0] : "";
LocationService.loadLocationsSubFor(subperf, currentCat[0]).then((value){ LatLngBounds bounds = mapController!.bounds!;
locations.add(value!); 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){ void setBound(LatLngBounds bounds){
@ -206,12 +263,14 @@ class IndexController extends GetxController {
loadSubPerfFor(perf); loadSubPerfFor(perf);
loadLocationforPerf(perf, mapController); loadLocationforPerf(perf, mapController);
zoomtoMainPerf(perf); zoomtoMainPerf(perf);
is_loading.value = false;
} }
void populateForSubPerf(String subperf, MapController mapController){ void populateForSubPerf(String subperf, MapController mapController){
subDropdownValue = subperf; subDropdownValue = subperf;
loadLocationforSubPerf(subperf, mapController); loadLocationforSubPerf(subperf, mapController);
zoomtoSubPerf(subperf); zoomtoSubPerf(subperf);
is_loading.value = false;
} }

View File

@ -5,6 +5,7 @@ import 'package:get/get.dart';
import 'package:rogapp/pages/drawer/drawer_page.dart'; import 'package:rogapp/pages/drawer/drawer_page.dart';
import 'package:rogapp/pages/index/index_controller.dart'; import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/routes/app_pages.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/bread_crum_widget.dart';
import 'package:rogapp/widgets/cat_widget.dart'; import 'package:rogapp/widgets/cat_widget.dart';
import 'package:rogapp/widgets/list_widget.dart'; import 'package:rogapp/widgets/list_widget.dart';
@ -72,7 +73,20 @@ class IndexPage extends GetView<IndexController> {
BreadCrumbWidget(), BreadCrumbWidget(),
Container(width: 24.0,), Container(width: 24.0,),
Obx(()=> 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,)
],
)
), ),
], ],
), ),

View File

@ -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,
)
);
}
}

View File

@ -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_binding.dart';
import 'package:rogapp/pages/index/index_page.dart'; import 'package:rogapp/pages/index/index_page.dart';
import 'package:rogapp/pages/landing/landing_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/login/login_page.dart';
import 'package:rogapp/pages/register/register_page.dart'; import 'package:rogapp/pages/register/register_page.dart';
import 'package:rogapp/spa/spa_binding.dart'; import 'package:rogapp/spa/spa_binding.dart';
@ -21,6 +22,7 @@ class AppPages {
static const LOGIN = Routes.LOGIN; static const LOGIN = Routes.LOGIN;
static const REGISTER = Routes.REGISTER; static const REGISTER = Routes.REGISTER;
static const TRAVEL = Routes.TRAVEL; static const TRAVEL = Routes.TRAVEL;
static const LOADING = Routes.LOADING;
static final routes = [ static final routes = [
// GetPage( // GetPage(
@ -62,6 +64,11 @@ class AppPages {
name: Routes.TRAVEL, name: Routes.TRAVEL,
page: () => DestinationPage(), page: () => DestinationPage(),
binding: DestinationBinding(), binding: DestinationBinding(),
),
GetPage(
name: Routes.LOADING,
page: () => LoadingPage(),
//binding: DestinationBinding(),
) )
]; ];
} }

View File

@ -12,4 +12,5 @@ abstract class Routes {
static const LOGIN = '/login'; static const LOGIN = '/login';
static const REGISTER = '/register'; static const REGISTER = '/register';
static const TRAVEL = '/travel'; static const TRAVEL = '/travel';
static const LOADING = '/loading';
} }

View File

@ -6,7 +6,7 @@ class ActionService{
static Future<Map<String, dynamic>> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async { static Future<Map<String, dynamic>> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async {
Map<String, dynamic> cats = {}; Map<String, dynamic> 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( final http.Response response = await http.get(
Uri.parse(url), Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
@ -23,7 +23,7 @@ class ActionService{
static Future<List<dynamic>?> userAction(int user_id, int location_id) async { static Future<List<dynamic>?> userAction(int user_id, int location_id) async {
List<dynamic> cats = []; List<dynamic> 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',

View File

@ -6,7 +6,7 @@ class AuthService{
static Future<Map<String, dynamic>> login(String email, String password) async { static Future<Map<String, dynamic>> login(String email, String password) async {
Map<String, dynamic> cats = {}; Map<String, dynamic> 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( final http.Response response = await http.post(
Uri.parse(url), Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
@ -27,7 +27,7 @@ class AuthService{
static Future<Map<String, dynamic>> register(String email, String password) async { static Future<Map<String, dynamic>> register(String email, String password) async {
Map<String, dynamic> cats = {}; Map<String, dynamic> 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( final http.Response response = await http.post(
Uri.parse(url), Uri.parse(url),
headers: <String, String>{ headers: <String, String>{

View File

@ -5,9 +5,12 @@ import 'package:http/http.dart' as http;
class CatService{ class CatService{
static Future<List<dynamic>?> loadCats() async { static Future<List<dynamic>?> loadCats(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4) async {
List<dynamic> cats = []; List<dynamic> 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
@ -26,3 +29,7 @@ class CatService{
} }

View File

@ -6,7 +6,7 @@ class DestinationService{
static Future<List<dynamic>> getDestinations(int user_id) async { static Future<List<dynamic>> getDestinations(int user_id) async {
List<dynamic> cats = []; List<dynamic> 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( final http.Response response = await http.get(
Uri.parse(url), Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
@ -22,7 +22,7 @@ class DestinationService{
static Future<int> updateOrder(int action_id, int order, String dir) async { static Future<int> updateOrder(int action_id, int order, String dir) async {
int cats = 0; 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( final http.Response response = await http.get(
Uri.parse(url), Uri.parse(url),
headers: <String, String>{ headers: <String, String>{

View File

@ -7,7 +7,7 @@ class LocationLineService{
final geo = GeoJson(); final geo = GeoJson();
GeoJsonFeature? fs; 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',

View File

@ -7,7 +7,7 @@ class LocationPolygonervice{
final geo = GeoJson(); final geo = GeoJson();
GeoJsonFeature? fs; 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',

View File

@ -6,7 +6,7 @@ import 'package:http/http.dart' as http;
class LocationService{ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocations() async { static Future<GeoJsonFeatureCollection?> 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
@ -23,11 +23,12 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async { static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
String url = ""; String url = "";
if(cat.isNotEmpty){ 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{ 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; //String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
final response = await http.get(Uri.parse(url), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
@ -47,10 +48,11 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async { static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async {
String url = ""; String url = "";
if(cat.isNotEmpty){ 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{ 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
@ -67,5 +69,38 @@ class LocationService{
} }
static Future<GeoJsonFeatureCollection?> 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: <String, String>{
'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;
}
} }

View File

@ -0,0 +1,44 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
class MatrixService{
static Future<Map<String, dynamic>> getDestinations(List<dynamic> destinations) async {
String locs = "";
String origin = "";
int i = 0;
for(Map<String, dynamic> 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<String, dynamic> 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: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
}
);
if (response.statusCode == 200) {
cats = json.decode(utf8.decode(response.bodyBytes));
}
return cats;
}
}

View File

@ -6,7 +6,7 @@ class PerfectureService{
static Future<List<dynamic>?> loadPerfectures() async { static Future<List<dynamic>?> loadPerfectures() async {
List<dynamic> perfs = []; List<dynamic> 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
@ -22,7 +22,7 @@ class PerfectureService{
static Future<List<dynamic>?> loadSubPerfectures(String sub) async { static Future<List<dynamic>?> loadSubPerfectures(String sub) async {
List<dynamic> perfs = []; List<dynamic> 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; //String url = 'http://container.intranet.sumasen.net:8100/api/insubperf/?perf=' + sub;
final response = await http.get(Uri.parse(url), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
@ -40,7 +40,7 @@ class PerfectureService{
static Future<List<dynamic>?> getMainPerfExt(String id) async { static Future<List<dynamic>?> getMainPerfExt(String id) async {
List<dynamic> perfs = []; List<dynamic> 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',
@ -57,7 +57,7 @@ class PerfectureService{
static Future<List<dynamic>?> getSubExt(String id) async { static Future<List<dynamic>?> getSubExt(String id) async {
List<dynamic> perfs = []; List<dynamic> 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), final response = await http.get(Uri.parse(url),
headers: <String, String>{ headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8', 'Content-Type': 'application/json; charset=UTF-8',

View File

@ -24,6 +24,7 @@ class _CatWidgetState extends State<CatWidget> {
widget.indexController.refreshLocationForCat(); widget.indexController.refreshLocationForCat();
setState(() { setState(() {
print(value); print(value);
//widget.indexController.is_loading.value = true;
defaultValue = value.toString(); defaultValue = value.toString();
}); });
}, },

View File

@ -1,3 +1,6 @@
import 'dart:async';
import 'dart:ffi';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart'; import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map_location_marker/flutter_map_location_marker.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); MapWidget({ Key? key}) : super(key: key);
StreamSubscription? subscription;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final PopupController _popupController = PopupController(); final PopupController _popupController = PopupController();
return Stack( return Stack(
children: [ children: [
Obx(() => Obx(() =>
indexController.is_loading == true ? Padding(
padding: const EdgeInsets.only(top: 60.0),
child: CircularProgressIndicator(),
):
FlutterMap( FlutterMap(
//mapController: mapController, //mapController: mapController,
options: MapOptions( 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), //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)]), bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
zoom: 1, zoom: 1,
@ -34,20 +59,75 @@ class MapWidget extends StatelessWidget {
plugins: [ plugins: [
MarkerClusterPlugin(), 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: (_, __) => onTap: (_, __) =>
_popupController _popupController
.hideAllPopups(), // Hide popup when the map is tapped. .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: [ children: [
BaseLayer(), BaseLayer(),
LocationMarkerLayerWidget(), LocationMarkerLayerWidget(),
indexController.locations.length > 0 ? indexController.locations.length > 0 ?
MarkerClusterLayerWidget( MarkerClusterLayerWidget(
options: MarkerClusterLayerOptions( options: MarkerClusterLayerOptions(
spiderfyCircleRadius: 80, spiderfyCircleRadius: 0,
spiderfySpiralDistanceMultiplier: 2, spiderfySpiralDistanceMultiplier: 2,
circleSpiralSwitchover: 12, circleSpiralSwitchover: 12,
maxClusterRadius: 20, maxClusterRadius: 0,
rotate: true, rotate: true,
onMarkerTap: (marker){ onMarkerTap: (marker){
GeoJsonFeature? fs = indexController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude); GeoJsonFeature? fs = indexController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude);

View File

@ -69,6 +69,7 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
onChanged: (String? newValue) { onChanged: (String? newValue) {
//setState(() { //setState(() {
if(newValue != null){ if(newValue != null){
widget.indexController.is_loading.value = true;
widget.indexController.dropdownValue = newValue; widget.indexController.dropdownValue = newValue;
widget.indexController.populateForPerf(newValue, widget.mapController); widget.indexController.populateForPerf(newValue, widget.mapController);
} }
@ -92,6 +93,7 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
onChanged: (String? newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
if(newValue != null){ if(newValue != null){
widget.indexController.is_loading.value = true;
widget.indexController.populateForSubPerf(newValue, widget.mapController); widget.indexController.populateForSubPerf(newValue, widget.mapController);
//widget.indexController.loadLocationforSubPerf(newValue, widget.mapController); //widget.indexController.loadLocationforSubPerf(newValue, widget.mapController);
//widget.indexController.subDropdownValue = newValue; //widget.indexController.subDropdownValue = newValue;

View File

@ -167,6 +167,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.5" 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: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -261,6 +268,27 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.3.1" 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: http:
dependency: transitive dependency: transitive
description: description:
@ -546,6 +574,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" 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: string_scanner:
dependency: transitive dependency: transitive
description: description:

View File

@ -61,6 +61,9 @@ dependencies:
url_launcher: ^6.0.20 url_launcher: ^6.0.20
flutter_breadcrumb: ^1.0.1 flutter_breadcrumb: ^1.0.1
timeline_tile: ^2.0.0 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: dev_dependencies: