update to routing
This commit is contained in:
@ -46,7 +46,7 @@ class DestinationController extends GetxController {
|
||||
void getRoutePoints() {
|
||||
indexController.routePoints = [];
|
||||
indexController.routePointLenght.value = 0;
|
||||
DestinationService.getDestinationLine(destinations)?.then((value){
|
||||
DestinationService.getDestinationLine(destinations, matrix)?.then((value){
|
||||
indexController.routePoints = value;
|
||||
indexController.routePointLenght.value = indexController.routePoints.length;
|
||||
});
|
||||
@ -272,8 +272,8 @@ class DestinationController extends GetxController {
|
||||
print("--------- destination controller populsting destinations ----------- ::::::");
|
||||
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
db.getDestinations().then((value){
|
||||
destinations.clear();
|
||||
db.getDestinations().then((value){
|
||||
destinationCount.value = 0;
|
||||
for(Destination d in value){
|
||||
for(Destination s in currentSelectedDestinations){
|
||||
|
||||
@ -105,17 +105,17 @@ class DestnationPage extends StatelessWidget {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
selected: destinationController.travelMode == 2 ? true : false,
|
||||
selectedTileColor: Colors.amber.shade200,
|
||||
leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
|
||||
title: Text("transit".tr),
|
||||
onTap:(){
|
||||
destinationController.travelMode.value = 2;
|
||||
destinationController.PopulateDestinations();
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
// ListTile(
|
||||
// selected: destinationController.travelMode == 2 ? true : false,
|
||||
// selectedTileColor: Colors.amber.shade200,
|
||||
// leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
|
||||
// title: Text("transit".tr),
|
||||
// onTap:(){
|
||||
// destinationController.travelMode.value = 2;
|
||||
// destinationController.PopulateDestinations();
|
||||
// Get.back();
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
|
||||
),
|
||||
|
||||
@ -305,7 +305,7 @@ void login(String email, String password, BuildContext context){
|
||||
|
||||
void loadAreaFor(String perf){
|
||||
areas.clear();
|
||||
dynamic initVal = {'id':'-1', 'adm2_ja':'----'};
|
||||
dynamic initVal = {'id':'-1', 'area_nm':'----'};
|
||||
PerfectureService.loadGifuAreas(perf).then((value){
|
||||
value!.add(initVal);
|
||||
areas.add(value);
|
||||
|
||||
@ -67,7 +67,7 @@ class DestinationService{
|
||||
return cats;
|
||||
}
|
||||
|
||||
static Future<List<PointLatLng>>? getDestinationLine(List<Destination> destinations) async{
|
||||
static Future<List<PointLatLng>>? getDestinationLine(List<Destination> destinations, Map<String, dynamic> mtx) async{
|
||||
PolylinePoints polylinePoints = PolylinePoints();
|
||||
|
||||
if(destinations.length <= 0){
|
||||
@ -88,28 +88,40 @@ class DestinationService{
|
||||
}
|
||||
double la = d.lat;
|
||||
double ln = d.lon;
|
||||
PolylineWayPoint pwp = PolylineWayPoint(location: "${la},${ln}", stopOver: true);
|
||||
|
||||
int j = 0;
|
||||
|
||||
PolylineWayPoint pwp = PolylineWayPoint(location: "${la},${ln}", stopOver: false);
|
||||
|
||||
|
||||
//print("----- UUUUUU ${pwp}");
|
||||
//PointLatLng wp = PointLatLng(d["Location"]["geometry"][0][1], d["Location"]["geometry"][0][0]);
|
||||
wayPoints.add(pwp);
|
||||
i+=1;
|
||||
j += 4;
|
||||
}
|
||||
|
||||
final DestinationController destinationController = Get.find<DestinationController>();
|
||||
int trav_mode = destinationController.travelMode.value;
|
||||
TravelMode _mode = TravelMode.walking;
|
||||
String _mode = "WALKING";
|
||||
if(trav_mode == 1){
|
||||
_mode = TravelMode.driving;
|
||||
//_mode = TravelMode.driving;
|
||||
_mode = "DRIVING";
|
||||
}
|
||||
else if(trav_mode == 2) {
|
||||
_mode = TravelMode.transit;
|
||||
//_mode = TravelMode.transit;
|
||||
_mode = "TRANSIT";
|
||||
}
|
||||
|
||||
|
||||
//PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", PointLatLng(35.389282, 136.498027), PointLatLng(36.285848, 137.575186));
|
||||
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", origin,dest, travelMode: _mode, wayPoints: wayPoints);
|
||||
Map<String, dynamic> pl = destinationController.matrix["routes"][0]["overview_polyline"];
|
||||
List<PointLatLng> result = polylinePoints.decodePolyline(pl["points"]);
|
||||
//List<PointLatLng> result = polylinePoints.decodePolyline("qkyvEq`z`Yp@DBMr@XL@Td@Eb@PREd@IFe@rKIzCY|GEvCBzCHvS@xC?HnBHtBHlBFnBFhGRtDVW~BE`@ICHLk@dE_ClPgAtHu@bFsAhPg@~Ge@bFaEtg@kEpi@oCd\\w@nIw@hGe@fBy@nBqAjC{@zBgBtFOd@M@Wv@i@`BQf@ITKCuE`@yDZqBRCHa@DKG_AHwBRiBR_Fp@y@LYBY]M@KJo@v@M@cAGoGN_Cx@}Cf@}@@mM~@qF`@gCLwBj@sBrAeAhAsAtCoF|MmAbD{@fBwAdBw@p@_Ax@BFOHAl@?`@MAQCEAOIQSaBx@{Ah@eATsAHSB?d@A`D?f@IdWy@AS??V?|BCJ}@?cA?k@Au@wBqDuKQaACg@z@gELg@GK~@uEp@{A@q@y@CHwFHcG?KDqCDK^ABABEH{AE{B{@_Ho@uFIaBFQhBaC@SQSg@k@g@q@Yw@qA{De@}B]uDCsAMEWDqAFu@@^A@TDjA@vDA`CETK|AEtAIFY@o@ALpBZ~HBlCBn@EDGPu@pASJO`@Qf@?ROr@K?qDLHnEUTsDNkENYB{Ab@I^?zA}CrCkBfBw@t@@LwA`Bo@r@eGvD}BrAGGuAj@[?i@rBVi@P}@T?F?^MxDuBhDsBzAcAn@s@zCgDAI~A{A|CsC?{A?UHItA_@DCXC~J_@TUIoEvDKTm@?Y^iALIb@k@f@aAE}AA_BC{@\\Cv@CxAEj@ExCwDDc@CYFANCh@WHEIIRQhB}B|C_E\\w@Hq@JE?a@O}CGkAIwEGmDEmDAKLA^?A}@C{@?e@E_DFQNi@LcB\\eBPsADGKOEWBOH[GCPs@Pq@\\cANs@^q@jAu@fCqAf@]HCXoCV_BVmAZmBVcDBeCCgDAaB?s@RE?aCCaEAyHAoDd@EJiD@_@AaAj@A\\A?Gp@@r@oBXm@LQ?IEy@Fy@tA[n@Gj@Tz@[~ACdAAx@Lp@Kr@]hAa@HAQoCMwCSwGSiGK_CCCKaBCgCOoCOgECwGB_OB{JHkBEmC?yCDyFF{QFue@BsYByE?oAEgAByLBiL?gLBuGXsEd@cCNA?OHa@jAuCn@eAtCyDh@k@v@EvBKr@EEkACUKaC?G~@gAlCeDFBT[jFeGZAfBEh@UpBM`AEMaFjFYIhE?hEPpCJzAPt@Fj@GNUFu@N[FyBbAuB`@_@LEIOB}@HUBQFk@FcAACGQA}@Bi@F@F[Dc@D[FQHELGhBMtDGR?D");
|
||||
//PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", origin,dest, travelMode: _mode, wayPoints: wayPoints);
|
||||
|
||||
//print("#####@@@@@ ${result.points}");
|
||||
return result.points;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ class MatrixService{
|
||||
|
||||
String locs = "";
|
||||
String origin = "";
|
||||
String destination = "";
|
||||
int i = 0;
|
||||
for(Destination d in destinations){
|
||||
|
||||
@ -21,6 +22,14 @@ class MatrixService{
|
||||
|
||||
if(i==0){
|
||||
origin = "${d.lat}, ${d.lon}";
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i == (destinations.length - 1)){
|
||||
destination = "${d.lat}, ${d.lon}";
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
print("lat is ${d.lat}, long is ${d.lon}");
|
||||
@ -28,6 +37,8 @@ class MatrixService{
|
||||
i++;
|
||||
}
|
||||
|
||||
locs = "optimize:false|${locs}";
|
||||
|
||||
String _mode = "walking";
|
||||
switch (destinationController.travelMode.value) {
|
||||
case 1:
|
||||
@ -42,7 +53,7 @@ class MatrixService{
|
||||
}
|
||||
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = "https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${locs}&mode=${_mode}&origins=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
|
||||
String url = "https://maps.googleapis.com/maps/api/directions/json?destination=${destination}&mode=${_mode}&waypoints=${locs}&origin=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
|
||||
print(url);
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
|
||||
@ -8,6 +8,6 @@ class ConstValues{
|
||||
static const dev_home_ip_server = "http://172.20.10.9:8100";
|
||||
|
||||
static String currentServer(){
|
||||
return dev_home_ip_server;
|
||||
return server_uri;
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,8 @@ class StringValues extends Translations{
|
||||
'confirm': 'Confirm',
|
||||
'cancel': 'Cancel',
|
||||
'all_destinations_are_deleted_successfully' : 'All destinations are deleted successfully',
|
||||
'deleted': "Deleted"
|
||||
'deleted': 'Deleted',
|
||||
'remarks' : 'Remarks'
|
||||
},
|
||||
'ja_JP': {
|
||||
'drawer_title':'ロゲイニング参加者はログイン するとチェックポイントが参照 できます',
|
||||
@ -83,7 +84,8 @@ class StringValues extends Translations{
|
||||
'confirm': '確認',
|
||||
'cancel': 'キャンセル',
|
||||
'all_destinations_are_deleted_successfully' : 'すべての宛先が正常に削除されました',
|
||||
'deleted': "削除された"
|
||||
'deleted': "削除された",
|
||||
'remarks' : '備考'
|
||||
},
|
||||
};
|
||||
}
|
||||
@ -111,7 +111,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
children: [
|
||||
MaterialButton(
|
||||
onPressed: () {
|
||||
destinationController.makePrevious(indexController.currentDestinationFeature[0]);
|
||||
Get.back();
|
||||
//destinationController.makePrevious(indexController.currentDestinationFeature[0]);
|
||||
},
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
@ -134,19 +135,19 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
),
|
||||
),
|
||||
),
|
||||
MaterialButton(
|
||||
onPressed: () {
|
||||
destinationController.makeNext(indexController.currentDestinationFeature[0]);
|
||||
},
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
child: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 14,
|
||||
),
|
||||
padding: EdgeInsets.all(16),
|
||||
shape: CircleBorder(),
|
||||
),
|
||||
// MaterialButton(
|
||||
// onPressed: () {
|
||||
// destinationController.makeNext(indexController.currentDestinationFeature[0]);
|
||||
// },
|
||||
// color: Colors.blue,
|
||||
// textColor: Colors.white,
|
||||
// child: Icon(
|
||||
// Icons.arrow_forward_ios,
|
||||
// size: 14,
|
||||
// ),
|
||||
// padding: EdgeInsets.all(16),
|
||||
// shape: CircleBorder(),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -223,7 +224,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
children: [
|
||||
MaterialButton(
|
||||
onPressed: () {
|
||||
indexController.makePrevious(indexController.currentFeature[0]);
|
||||
Get.back();
|
||||
//indexController.makePrevious(indexController.currentFeature[0]);
|
||||
},
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
@ -246,20 +248,20 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
),
|
||||
),
|
||||
),
|
||||
MaterialButton(
|
||||
onPressed: () {
|
||||
//print("----- next is ${indexController.currentFeature[0]} ------");
|
||||
indexController.makeNext(indexController.currentFeature[0]);
|
||||
},
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
child: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 14,
|
||||
),
|
||||
padding: EdgeInsets.all(16),
|
||||
shape: CircleBorder(),
|
||||
),
|
||||
// MaterialButton(
|
||||
// onPressed: () {
|
||||
// //print("----- next is ${indexController.currentFeature[0]} ------");
|
||||
// indexController.makeNext(indexController.currentFeature[0]);
|
||||
// },
|
||||
// color: Colors.blue,
|
||||
// textColor: Colors.white,
|
||||
// child: Icon(
|
||||
// Icons.arrow_forward_ios,
|
||||
// size: 14,
|
||||
// ),
|
||||
// padding: EdgeInsets.all(16),
|
||||
// shape: CircleBorder(),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -365,7 +367,19 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
],
|
||||
),
|
||||
),
|
||||
Text('id: ${indexController.currentFeature[0].properties!["location_id"].toString()}, cp : ${indexController.currentFeature[0].properties!["cp"].toString()}'),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 8.0,),
|
||||
indexController.currentFeature[0].properties!["remark"] != null && (indexController.currentFeature[0].properties!["remark"] as String).isNotEmpty ?
|
||||
getDetails(context, "remarks".tr, indexController.currentFeature[0].properties!["remark"] ?? '', isurl: false)
|
||||
:
|
||||
Container(width: 0.0, height: 0,),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text('${indexController.currentFeature[0].properties!["cp"].toString()} - id: ${indexController.currentFeature[0].properties!["checkin_point"].toString()}'),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
@ -26,6 +26,8 @@ class DestinationWidget extends StatelessWidget {
|
||||
}
|
||||
else{
|
||||
print("------- image is ${destinationController.destinations[index].photos!}------");
|
||||
String _photo = destinationController.destinations[index].photos!;
|
||||
if(_photo.contains('http')){
|
||||
return Image(image: NetworkImage(
|
||||
destinationController.destinations[index].photos!),
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
@ -33,6 +35,16 @@ class DestinationWidget extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
}
|
||||
else {
|
||||
return Image(image: NetworkImage(
|
||||
'http://container.intranet.sumasen.net:8100/media/' + destinationController.destinations[index].photos!),
|
||||
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
|
||||
return Image.asset("assets/images/empty_image.png");
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool getSelection(int index){
|
||||
@ -221,12 +233,12 @@ class DestinationWidget extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
startChild:
|
||||
destinationController.matrix["rows"][0]["elements"] != null ?
|
||||
index > 0 && destinationController.matrix["routes"][0]["legs"] != null ?
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Text(destinationController.matrix["rows"][0]["elements"][index]["distance"] != null ? destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString(): ''),
|
||||
Text(destinationController.matrix["rows"][0]["elements"][index]["distance"] != null ? destinationController.matrix["rows"][0]["elements"][index]["duration"]["text"].toString() : '')
|
||||
Text(destinationController.matrix["routes"][0]["legs"][index -1]["distance"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["distance"]["text"].toString(): ''),
|
||||
Text(destinationController.matrix["routes"][0]["legs"][index -1]["duration"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["duration"]["text"].toString() : '')
|
||||
],
|
||||
):
|
||||
Container()
|
||||
|
||||
@ -43,10 +43,10 @@ class MapWidget extends StatelessWidget {
|
||||
Icon(Icons.circle,size: 6.0,),
|
||||
i.properties!['cp'] == -1 ?
|
||||
Transform.rotate(
|
||||
alignment: Alignment.center,
|
||||
origin: Offset.fromDirection(0, 6),
|
||||
angle: 90 * pi / 180,
|
||||
child: Icon(Icons.play_arrow_outlined, color: Colors.red, size: 40,)):
|
||||
alignment: Alignment.centerLeft,
|
||||
origin: Offset.fromDirection(1, 26),
|
||||
angle: 270 * pi / 180,
|
||||
child: Icon(Icons.play_arrow_outlined, color: Colors.red, size: 70,)):
|
||||
Container(color: Colors.transparent,),
|
||||
],
|
||||
)
|
||||
|
||||
@ -60,7 +60,6 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
|
||||
child: Text(currency["adm2_ja"].toString()),
|
||||
value: currency["id"].toString(),
|
||||
);
|
||||
|
||||
dropDownItems.add(newDropdown);
|
||||
}
|
||||
}
|
||||
@ -76,8 +75,8 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
|
||||
child: Text(currency["area_nm"].toString()),
|
||||
value: currency["id"].toString(),
|
||||
);
|
||||
|
||||
dropDownItems.add(newDropdown);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user