map updated to 6
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:camera_camera/camera_camera.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@ -26,7 +27,8 @@ import 'dart:async';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
import 'package:rogapp/widgets/debug_widget.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:gallery_saver/gallery_saver.dart';
|
||||
|
||||
import 'package:image_gallery_saver/image_gallery_saver.dart';
|
||||
|
||||
class DestinationController extends GetxController {
|
||||
late LocationSettings locationSettings;
|
||||
@ -79,10 +81,9 @@ class DestinationController extends GetxController {
|
||||
return DateFormat('yyyy-MM-dd HH:mm:ss').format(datetime);
|
||||
}
|
||||
|
||||
Destination festuretoDestination(GeoJsonFeature fs) {
|
||||
GeoJsonMultiPoint mp = fs.geometry as GeoJsonMultiPoint;
|
||||
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude,
|
||||
mp.geoSerie!.geoPoints[0].longitude);
|
||||
Destination festuretoDestination(GeoJSONFeature fs) {
|
||||
GeoJSONMultiPoint mp = fs.geometry as GeoJSONMultiPoint;
|
||||
LatLng pt = LatLng(mp.coordinates[0][1], mp.coordinates[0][0]);
|
||||
|
||||
//print("----- ${indexController.currentFeature[0].properties} -----");
|
||||
|
||||
@ -112,7 +113,7 @@ class DestinationController extends GetxController {
|
||||
tags: fs.properties!["tags"]);
|
||||
}
|
||||
|
||||
Future<void> startTimerLocation(GeoJsonFeature fs, double distance) async {
|
||||
Future<void> startTimerLocation(GeoJSONFeature fs, double distance) async {
|
||||
//print("---- in startTimer ----");
|
||||
// print("---- is in rog is $is_in_rog ----");
|
||||
double checkinRadious = fs.properties!['checkin_radius'] ?? double.infinity;
|
||||
@ -570,32 +571,23 @@ class DestinationController extends GetxController {
|
||||
// created_at: DateTime.now().microsecondsSinceEpoch);
|
||||
// await db.insertGps(gps_data);
|
||||
|
||||
for (GeoJsonFeature fs in indexController.locations[0].collection) {
|
||||
GeoJsonMultiPoint mp = fs.geometry as GeoJsonMultiPoint;
|
||||
LatLng pt = LatLng(mp.geoSerie!.geoPoints[0].latitude,
|
||||
mp.geoSerie!.geoPoints[0].longitude);
|
||||
indexController.locations[0].features.forEach((fs) async {
|
||||
GeoJSONMultiPoint mp = fs!.geometry as GeoJSONMultiPoint;
|
||||
LatLng pt = LatLng(mp.coordinates[0][1], mp.coordinates[0][0]);
|
||||
|
||||
double latFs = pt.latitude;
|
||||
double lonFs = pt.longitude;
|
||||
var distanceFs = const Distance();
|
||||
//print("--- points : ${pt.latitude}, ${pt.longitude} ----");
|
||||
//print("--- points : ${pt.latitude}, ${pt.longitude} ----");
|
||||
double distFs = distanceFs.as(
|
||||
LengthUnit.Meter, LatLng(latFs, lonFs), LatLng(la, ln));
|
||||
Destination des = festuretoDestination(fs);
|
||||
|
||||
//print(
|
||||
// "--- position is ---- ${position.longitude}, --- ${position.longitude}----");
|
||||
|
||||
//print("--- distFs ---- $distFs, --- ${des.checkin_radious}----");
|
||||
if (distFs <= des.checkin_radious! && skipGps == false) {
|
||||
//print("--- 789 ---- $skip_gps----");
|
||||
//near a location
|
||||
//print("---- before call startTimerLocation ----");
|
||||
await startTimerLocation(fs, distFs);
|
||||
break;
|
||||
// Note: You cannot break out of forEach. If you need to stop processing, you might have to reconsider using forEach.
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (gps_push_started == false) {
|
||||
pushGPStoServer();
|
||||
}
|
||||
@ -644,11 +636,21 @@ class DestinationController extends GetxController {
|
||||
populateDestinations();
|
||||
}
|
||||
|
||||
_saveImageFromPath(String imagePath) async {
|
||||
// Read the image file from the given path
|
||||
File imageFile = File(imagePath);
|
||||
Uint8List imageBytes = await imageFile.readAsBytes();
|
||||
|
||||
// Save the image to the gallery
|
||||
final result = await ImageGallerySaver.saveImage(imageBytes);
|
||||
print(result);
|
||||
}
|
||||
|
||||
Future<void> makeBuyPoint(Destination destination, String imageurl) async {
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
await db.updateBuyPoint(destination, imageurl);
|
||||
populateDestinations();
|
||||
await GallerySaver.saveImage(imageurl);
|
||||
await _saveImageFromPath(imageurl);
|
||||
|
||||
if (indexController.currentUser.isNotEmpty) {
|
||||
double cpNum = destination.cp!;
|
||||
@ -690,7 +692,7 @@ class DestinationController extends GetxController {
|
||||
// print("~~~~ inserted into db ~~~~");
|
||||
}
|
||||
|
||||
await GallerySaver.saveImage(imageurl);
|
||||
await _saveImageFromPath(imageurl);
|
||||
|
||||
populateDestinations();
|
||||
|
||||
@ -740,14 +742,23 @@ class DestinationController extends GetxController {
|
||||
|
||||
double distanceToStart() {
|
||||
//print("=== gfs len == ${indexController.locations[0].collection.length}");
|
||||
GeoJsonFeature gfs = indexController.locations[0].collection
|
||||
.firstWhere((element) => festuretoDestination(element).cp == -1);
|
||||
double distanceToDest = double.infinity;
|
||||
if (indexController.locations[0].features.isEmpty) {
|
||||
return distanceToDest;
|
||||
}
|
||||
GeoJSONFeature? gfs = indexController.locations[0].features.firstWhere(
|
||||
(element) => festuretoDestination(element!).cp == -1,
|
||||
orElse: () => null, // Provide a null value if no element is found
|
||||
);
|
||||
|
||||
if (gfs == null) {
|
||||
return distanceToDest;
|
||||
}
|
||||
|
||||
Destination des = festuretoDestination(gfs);
|
||||
|
||||
//print("=== gfs == ${des.toMap()}");
|
||||
|
||||
double distanceToDest = double.infinity;
|
||||
var distance = const Distance();
|
||||
distanceToDest = distance.as(LengthUnit.Meter,
|
||||
LatLng(currentLat, currentLon), LatLng(des.lat!, des.lon!));
|
||||
@ -761,8 +772,14 @@ class DestinationController extends GetxController {
|
||||
return 500;
|
||||
}
|
||||
Destination? ds;
|
||||
GeoJsonFeature gfs = indexController.locations[0].collection
|
||||
.firstWhere((element) => festuretoDestination(element).cp == -1);
|
||||
GeoJSONFeature? gfs = indexController.locations[0].features.firstWhere(
|
||||
(element) => festuretoDestination(element!).cp == -1,
|
||||
orElse: () => null, // Provide a null value if no element is found
|
||||
);
|
||||
|
||||
if (gfs == null) {
|
||||
return _retValue;
|
||||
}
|
||||
|
||||
ds = festuretoDestination(gfs);
|
||||
var distance = const Distance();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:flutter_map_marker_popup/flutter_map_marker_popup.dart';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
@ -42,64 +42,61 @@ class DestinationMapPage extends StatelessWidget {
|
||||
//print("^^^^ $d ^^^^");
|
||||
Marker m = Marker(
|
||||
point: LatLng(d.lat!, d.lon!),
|
||||
anchorPos: AnchorPos.align(AnchorAlign.center),
|
||||
builder: (cts) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
//print("-- Destination is --- ${d.name} ------");
|
||||
if (indexController.currentDestinationFeature.isNotEmpty) {
|
||||
indexController.currentDestinationFeature.clear();
|
||||
}
|
||||
indexController.currentDestinationFeature.add(d);
|
||||
//indexController.getAction();
|
||||
alignment: Alignment.topCenter,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
//print("-- Destination is --- ${d.name} ------");
|
||||
if (indexController.currentDestinationFeature.isNotEmpty) {
|
||||
indexController.currentDestinationFeature.clear();
|
||||
}
|
||||
indexController.currentDestinationFeature.add(d);
|
||||
//indexController.getAction();
|
||||
|
||||
showModalBottomSheet(
|
||||
context: Get.context!,
|
||||
isScrollControlled: true,
|
||||
constraints: BoxConstraints.loose(
|
||||
Size(Get.width, Get.height * 0.85)),
|
||||
builder: ((context) => BottomSheetNew(
|
||||
destination: d,
|
||||
))).whenComplete(() {
|
||||
//print("---- set skip gps to false -----");
|
||||
destinationController.skipGps = false;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width:
|
||||
d.checkin_radious != null ? d.checkin_radious! : 1,
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
(i + 1).toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
showModalBottomSheet(
|
||||
context: Get.context!,
|
||||
isScrollControlled: true,
|
||||
constraints:
|
||||
BoxConstraints.loose(Size(Get.width, Get.height * 0.85)),
|
||||
builder: ((context) => BottomSheetNew(
|
||||
destination: d,
|
||||
))).whenComplete(() {
|
||||
//print("---- set skip gps to false -----");
|
||||
destinationController.skipGps = false;
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: d.checkin_radious != null ? d.checkin_radious! : 1,
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Colors.yellow,
|
||||
child: Text(
|
||||
TextUtils.getDisplayText(d),
|
||||
style: const TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
overflow: TextOverflow.visible),
|
||||
)),
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
child: Center(
|
||||
child: Text(
|
||||
(i + 1).toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
color: Colors.yellow,
|
||||
child: Text(
|
||||
TextUtils.getDisplayText(d),
|
||||
style: const TextStyle(
|
||||
fontSize: 15.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
overflow: TextOverflow.visible),
|
||||
)),
|
||||
],
|
||||
),
|
||||
));
|
||||
|
||||
pts.add(m);
|
||||
}
|
||||
|
||||
@ -126,19 +126,11 @@ class _GpsPageState extends State<GpsPage> {
|
||||
MarkerLayer(
|
||||
markers: gpsData.map((i) {
|
||||
return Marker(
|
||||
anchorPos: AnchorPos.exactly(Anchor(108.0, 18.0)),
|
||||
height: 32.0,
|
||||
width: 120.0,
|
||||
point: LatLng(i.lat, i.lon),
|
||||
builder: (ctx) {
|
||||
return getMarkerShape(i);
|
||||
// return Container(
|
||||
// width: 40,
|
||||
// height: 40,
|
||||
// color: Colors.orange,
|
||||
// );
|
||||
},
|
||||
);
|
||||
alignment: Alignment.topCenter,
|
||||
height: 32.0,
|
||||
width: 120.0,
|
||||
point: LatLng(i.lat, i.lon),
|
||||
child: getMarkerShape(i));
|
||||
}).toList(),
|
||||
)
|
||||
],
|
||||
|
||||
@ -4,9 +4,8 @@ import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
@ -18,8 +17,8 @@ import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class IndexController extends GetxController {
|
||||
List<GeoJsonFeatureCollection> locations = <GeoJsonFeatureCollection>[].obs;
|
||||
List<GeoJsonFeature> currentFeature = <GeoJsonFeature>[].obs;
|
||||
List<GeoJSONFeatureCollection> locations = <GeoJSONFeatureCollection>[].obs;
|
||||
List<GeoJSONFeature> currentFeature = <GeoJSONFeature>[].obs;
|
||||
List<Destination> currentDestinationFeature = <Destination>[].obs;
|
||||
List<dynamic> perfectures = <dynamic>[].obs;
|
||||
List<LatLngBounds> currentBound = <LatLngBounds>[].obs;
|
||||
@ -311,7 +310,7 @@ class IndexController extends GetxController {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
if (value.collection.isEmpty) {
|
||||
if (value.features.isEmpty) {
|
||||
if (showPopup == false) {
|
||||
return;
|
||||
}
|
||||
@ -328,7 +327,7 @@ class IndexController extends GetxController {
|
||||
showPopup = false;
|
||||
//Get.showSnackbar(GetSnackBar(message: "Too many points, please zoom in",));
|
||||
}
|
||||
if (value.collection.isNotEmpty) {
|
||||
if (value.features.isNotEmpty) {
|
||||
////print("---- added---");
|
||||
locations.add(value);
|
||||
}
|
||||
@ -340,15 +339,18 @@ class IndexController extends GetxController {
|
||||
currentBound.add(bounds);
|
||||
}
|
||||
|
||||
GeoJsonFeature? getFeatureForLatLong(double lat, double long) {
|
||||
GeoJSONFeature? getFeatureForLatLong(double lat, double long) {
|
||||
if (locations.isNotEmpty) {
|
||||
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;
|
||||
GeoJSONFeature? foundFeature;
|
||||
|
||||
locations[0].features.forEach((i) {
|
||||
GeoJSONMultiPoint p = i!.geometry as GeoJSONMultiPoint;
|
||||
if (p.coordinates[0][1] == lat && p.coordinates[0][0] == long) {
|
||||
foundFeature = i;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return foundFeature;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,23 +1,21 @@
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
|
||||
class SearchBarController extends GetxController {
|
||||
List<GeoJSONFeature> searchResults = <GeoJSONFeature>[].obs;
|
||||
|
||||
List<GeoJsonFeature> searchResults = <GeoJsonFeature>[].obs;
|
||||
|
||||
|
||||
@override
|
||||
@override
|
||||
void onInit() {
|
||||
IndexController indexController = Get.find<IndexController>();
|
||||
if(indexController.locations.isNotEmpty){
|
||||
for(int i=0; i<= indexController.locations[0].collection.length - 1; i++){
|
||||
GeoJsonFeature p = indexController.locations[0].collection[i];
|
||||
if (indexController.locations.isNotEmpty) {
|
||||
for (int i = 0;
|
||||
i <= indexController.locations[0].features.length - 1;
|
||||
i++) {
|
||||
GeoJSONFeature p = indexController.locations[0].features[i]!;
|
||||
searchResults.add(p);
|
||||
}
|
||||
}
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
@ -48,46 +48,32 @@ class SearchPage extends StatelessWidget {
|
||||
//title: const CupertinoSearchTextField(),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: TypeAheadField(
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
autofocus: true,
|
||||
style: DefaultTextStyle.of(context).style.copyWith(
|
||||
fontStyle: FontStyle.normal,
|
||||
fontSize: 15.0,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
hintText: "検索",
|
||||
prefixIcon: const Icon(Icons.search),
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
// clear the text field
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
suggestionsCallback: (pattern) async {
|
||||
return searchController.searchResults.where(
|
||||
(GeoJsonFeature element) => element.properties!["location_name"]
|
||||
.toString()
|
||||
.contains(pattern));
|
||||
//return await
|
||||
},
|
||||
itemBuilder: (context, GeoJsonFeature suggestion) {
|
||||
return ListTile(
|
||||
title: Text(suggestion.properties!["location_name"]),
|
||||
subtitle: suggestion.properties!["category"] != null
|
||||
? Text(suggestion.properties!["category"])
|
||||
: const Text(""),
|
||||
//leading: getImage(index),
|
||||
);
|
||||
},
|
||||
onSuggestionSelected: (GeoJsonFeature suggestion) {
|
||||
child: TypeAheadField<GeoJSONFeature>(
|
||||
// textFieldConfiguration: TextFieldConfiguration(
|
||||
// autofocus: true,
|
||||
// style: DefaultTextStyle.of(context).style.copyWith(
|
||||
// fontStyle: FontStyle.normal,
|
||||
// fontSize: 15.0,
|
||||
// ),
|
||||
// decoration: InputDecoration(
|
||||
// border: const OutlineInputBorder(),
|
||||
// hintText: "検索",
|
||||
// prefixIcon: const Icon(Icons.search),
|
||||
// suffixIcon: IconButton(
|
||||
// icon: const Icon(Icons.clear),
|
||||
// onPressed: () {
|
||||
// // clear the text field
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
onSelected: (GeoJSONFeature suggestion) {
|
||||
indexController.currentFeature.clear();
|
||||
indexController.currentFeature.add(suggestion);
|
||||
DestinationController destinationController = Get.find<DestinationController>();
|
||||
Destination des = destinationController.festuretoDestination(suggestion);
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
Destination des =
|
||||
destinationController.festuretoDestination(suggestion);
|
||||
Get.back();
|
||||
showModalBottomSheet(
|
||||
constraints:
|
||||
@ -95,7 +81,28 @@ class SearchPage extends StatelessWidget {
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
//builder: (context) => BottomSheetWidget(),
|
||||
builder: ((context) => BottomSheetNew(destination: des,)));
|
||||
builder: ((context) => BottomSheetNew(
|
||||
destination: des,
|
||||
)));
|
||||
},
|
||||
|
||||
suggestionsCallback: (pattern) async {
|
||||
return searchController.searchResults
|
||||
.where((GeoJSONFeature element) => element
|
||||
.properties!["location_name"]
|
||||
.toString()
|
||||
.contains(pattern))
|
||||
.toList();
|
||||
//return await
|
||||
},
|
||||
itemBuilder: (context, GeoJSONFeature suggestion) {
|
||||
return ListTile(
|
||||
title: Text(suggestion.properties!["location_name"]),
|
||||
subtitle: suggestion.properties!["category"] != null
|
||||
? Text(suggestion.properties!["category"])
|
||||
: const Text(""),
|
||||
//leading: getImage(index),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
@ -1,32 +1,32 @@
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
// import 'package:geojson/geojson.dart';
|
||||
// import 'package:http/http.dart' as http;
|
||||
|
||||
import '../utils/const.dart';
|
||||
// import '../utils/const.dart';
|
||||
|
||||
class LocationLineService {
|
||||
static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
final geo = GeoJson();
|
||||
GeoJsonFeature? fs;
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/location_line/';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
// class LocationLineService {
|
||||
// static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
// final geo = GeoJson();
|
||||
// GeoJsonFeature? fs;
|
||||
// String serverUrl = ConstValues.currentServer();
|
||||
// String url = '$serverUrl/api/location_line/';
|
||||
// //print('++++++++$url');
|
||||
// final response = await http.get(
|
||||
// Uri.parse(url),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||
// },
|
||||
// );
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
geo.processedFeatures.listen((fst) {
|
||||
fs = fst;
|
||||
});
|
||||
// if (response.statusCode == 200) {
|
||||
// geo.processedFeatures.listen((fst) {
|
||||
// fs = fst;
|
||||
// });
|
||||
|
||||
await geo.parse(response.body, verbose: true);
|
||||
// await geo.parse(response.body, verbose: true);
|
||||
|
||||
return fs;
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
}
|
||||
// return fs;
|
||||
// } else {
|
||||
// throw Exception('Failed to create album.');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
// import 'package:geojson/geojson.dart';
|
||||
// import 'package:http/http.dart' as http;
|
||||
|
||||
import '../utils/const.dart';
|
||||
// import '../utils/const.dart';
|
||||
|
||||
class LocationPolygonervice {
|
||||
static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
final geo = GeoJson();
|
||||
GeoJsonFeature? fs;
|
||||
// class LocationPolygonervice {
|
||||
// static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
// final geo = GeoJson();
|
||||
// GeoJsonFeature? fs;
|
||||
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/location_polygon/';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
// String serverUrl = ConstValues.currentServer();
|
||||
// String url = '$serverUrl/api/location_polygon/';
|
||||
// //print('++++++++$url');
|
||||
// final response = await http.get(
|
||||
// Uri.parse(url),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||
// },
|
||||
// );
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
geo.processedFeatures.listen((fst) {
|
||||
fs = fst;
|
||||
});
|
||||
// if (response.statusCode == 200) {
|
||||
// geo.processedFeatures.listen((fst) {
|
||||
// fs = fst;
|
||||
// });
|
||||
|
||||
await geo.parse(response.body, verbose: true);
|
||||
// await geo.parse(response.body, verbose: true);
|
||||
|
||||
return fs;
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
}
|
||||
// return fs;
|
||||
// } else {
|
||||
// throw Exception('Failed to create album.');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,39 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
|
||||
class LocationService {
|
||||
// static Future<GeoJsonFeatureCollection?> loadLocations() async {
|
||||
|
||||
// final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
// String server_url = ConstValues.currentServer();
|
||||
// String url = "";
|
||||
// if(indexController.currentUser.length > 0){
|
||||
// url = '${server_url}/api/location/?is_rog=True';
|
||||
// }
|
||||
// else {
|
||||
// url = '${server_url}/api/location/';
|
||||
// }
|
||||
// //String url = 'http://localhost:8100/api/location/';
|
||||
// final response = await http.get(Uri.parse(url),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||
// },
|
||||
// );
|
||||
|
||||
// if (response.statusCode == 200) {
|
||||
|
||||
// return featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsFor(
|
||||
static Future<GeoJSONFeatureCollection?> loadLocationsFor(
|
||||
String perfecture, String cat) async {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
String url = "";
|
||||
@ -67,8 +41,8 @@ class LocationService {
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
GeoJSONFeatureCollection cc =
|
||||
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||
//print(cc);
|
||||
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
@ -95,48 +69,7 @@ class LocationService {
|
||||
return ext;
|
||||
}
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(
|
||||
String subperfecture, String cat) async {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
String url = "";
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
if (cat.isNotEmpty) {
|
||||
if (indexController.currentUser.isNotEmpty) {
|
||||
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
|
||||
String r = rog == true ? 'True' : 'False';
|
||||
var grp = indexController.currentUser[0]['user']['event_code'];
|
||||
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture&cat=$cat';
|
||||
} else {
|
||||
url = '$serverUrl/api/insubperf?subperf=$subperfecture&cat=$cat';
|
||||
}
|
||||
} else {
|
||||
if (indexController.currentUser.isNotEmpty) {
|
||||
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
|
||||
String r = rog == true ? 'True' : 'False';
|
||||
var grp = indexController.currentUser[0]['user']['event_code'];
|
||||
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture';
|
||||
} else {
|
||||
url = '$serverUrl/api/insubperf?subperf=$subperfecture';
|
||||
}
|
||||
}
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
//print(cc);
|
||||
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsBound(
|
||||
static Future<GeoJSONFeatureCollection?> loadLocationsBound(
|
||||
double lat1,
|
||||
double lon1,
|
||||
double lat2,
|
||||
@ -183,13 +116,15 @@ class LocationService {
|
||||
);
|
||||
|
||||
if (response.statusCode == 500) {
|
||||
return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
return null; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
if (cc.collection.isEmpty) {
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
GeoJSONFeatureCollection cc =
|
||||
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||
if (cc.features.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
//print("---- feature got from server is ${cc.collection[0].properties} ------");
|
||||
@ -199,7 +134,7 @@ class LocationService {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadCustomLocations(
|
||||
static Future<GeoJSONFeatureCollection?> loadCustomLocations(
|
||||
String name, String cat) async {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
String url = "";
|
||||
@ -236,13 +171,13 @@ class LocationService {
|
||||
);
|
||||
|
||||
if (response.statusCode == 500) {
|
||||
return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
return null; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
if (cc.collection.isEmpty) {
|
||||
GeoJSONFeatureCollection cc =
|
||||
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||
if (cc.features.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
return cc;
|
||||
|
||||
145
lib/utils/location_controller.dart
Normal file
145
lib/utils/location_controller.dart
Normal file
@ -0,0 +1,145 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
|
||||
class LocationController extends GetxController {
|
||||
// Reactive variable to hold the current position
|
||||
Rx<Position?> currentPosition = Rx<Position?>(null);
|
||||
|
||||
// Subscription to the position stream
|
||||
StreamSubscription<Position>? positionStream;
|
||||
bool isStreamPaused = false;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
// Start listening to location updates when the controller is initialized
|
||||
startPositionStream();
|
||||
}
|
||||
|
||||
void startPositionStream() async {
|
||||
// Check for location service and permissions before starting the stream
|
||||
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
if (!serviceEnabled) {
|
||||
// Use GetX's context to show a dialog
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text('Location Services Disabled'),
|
||||
content: const Text(
|
||||
'Please enable location services to continue using the app.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
// Close the dialog
|
||||
Get.back();
|
||||
// Optionally, you can direct the user to the settings page
|
||||
// Geolocator.openLocationSettings();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
barrierDismissible: false, // User must tap button to close dialog
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
permission = await Geolocator.requestPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
// Show a dialog if permissions are still denied
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text('Location Permission Denied'),
|
||||
content: const Text(
|
||||
'This app requires location permissions to function properly. Please enable location permissions in your device settings.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
// Close the dialog
|
||||
Get.back();
|
||||
// Optionally, direct the user to the app settings
|
||||
// Geolocator.openAppSettings();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
barrierDismissible: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (permission == LocationPermission.deniedForever) {
|
||||
// Show a dialog if permissions are permanently denied
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text('Location Permission Needed'),
|
||||
content: const Text(
|
||||
'Location permissions have been permanently denied. Please open app settings to enable location permissions.'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: const Text('Open Settings'),
|
||||
onPressed: () {
|
||||
// Close the dialog and open app settings
|
||||
Get.back();
|
||||
Geolocator.openAppSettings();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
barrierDismissible: false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the location options
|
||||
const locationOptions = LocationSettings(
|
||||
accuracy: LocationAccuracy.bestForNavigation,
|
||||
distanceFilter: 0,
|
||||
timeLimit: Duration(microseconds: 2500),
|
||||
);
|
||||
|
||||
// Start listening to the position stream
|
||||
positionStream =
|
||||
Geolocator.getPositionStream(locationSettings: locationOptions).listen(
|
||||
(Position position) {
|
||||
currentPosition.value = position;
|
||||
}, onError: (e) {
|
||||
// Handle errors or exceptions in the stream
|
||||
// You might want to log this error or use a state to show error messages
|
||||
});
|
||||
|
||||
// Resume stream if it was paused previously
|
||||
if (isStreamPaused) {
|
||||
positionStream?.resume();
|
||||
isStreamPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Method to stop the position stream
|
||||
void stopPositionStream() {
|
||||
if (positionStream != null) {
|
||||
positionStream!.pause();
|
||||
isStreamPaused = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Method to resume the position stream
|
||||
void resumePositionStream() {
|
||||
if (positionStream != null && isStreamPaused) {
|
||||
positionStream!.resume();
|
||||
isStreamPaused = false;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// Cancel the position stream subscription when the controller is closed
|
||||
positionStream?.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
|
||||
class TextUtils {
|
||||
static String getDisplayTextFeture(GeoJsonFeature f) {
|
||||
static String getDisplayTextFeture(GeoJSONFeature f) {
|
||||
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||
String txt = "";
|
||||
// if(f.properties!["cp"] > 0){
|
||||
|
||||
@ -8,17 +8,14 @@ class BaseLayer extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TileLayer(
|
||||
urlTemplate: "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
|
||||
tileProvider: FMTC.instance('OpenStreetMap (A)').getTileProvider(
|
||||
FMTCTileProviderSettings(
|
||||
behavior: CacheBehavior.values
|
||||
.byName('cacheFirst'),
|
||||
cachedValidDuration: const Duration(
|
||||
days: 14
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
urlTemplate: "https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
|
||||
tileProvider: FMTC.instance('OpenStreetMap (A)').getTileProvider(
|
||||
settings: FMTCTileProviderSettings(
|
||||
behavior: CacheBehavior.values.byName('cacheFirst'),
|
||||
cachedValidDuration: const Duration(days: 14),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,8 @@
|
||||
|
||||
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get_state_manager/get_state_manager.dart';
|
||||
|
||||
class BottomSheetController extends GetxController{
|
||||
|
||||
List<GeoJsonFeature>? currentFeature = <GeoJsonFeature>[];
|
||||
class BottomSheetController extends GetxController {
|
||||
List<GeoJSONFeature>? currentFeature = <GeoJSONFeature>[];
|
||||
|
||||
BottomSheetController({this.currentFeature});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
@ -11,14 +10,12 @@ import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/camera/camera_page.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/services/external_service.dart';
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
import 'package:rogapp/utils/database_helper.dart';
|
||||
import 'package:rogapp/utils/text_util.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_controller.dart';
|
||||
import 'package:rogapp/widgets/debug_widget.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
@ -65,7 +62,7 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GeoJsonFeature<dynamic> gf = indexController.currentFeature[0];
|
||||
GeoJSONFeature gf = indexController.currentFeature[0];
|
||||
//print("=== photo sss ${gf.properties!["photos"]}");
|
||||
if (gf.properties!["photos"] == null || gf.properties!["photos"] == "") {
|
||||
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
@ -584,9 +581,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
onPressed: () async {
|
||||
Get.back();
|
||||
//print("---- go to ----");
|
||||
GeoJsonFeature<GeoJsonMultiPoint> mp =
|
||||
indexController.currentFeature[0]
|
||||
as GeoJsonFeature<GeoJsonMultiPoint>;
|
||||
GeoJSONMultiPoint mp = indexController
|
||||
.currentFeature[0] as GeoJSONMultiPoint;
|
||||
Position position =
|
||||
await Geolocator.getCurrentPosition(
|
||||
desiredAccuracy:
|
||||
@ -598,10 +594,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
|
||||
lon: position.longitude);
|
||||
|
||||
Destination tp = Destination(
|
||||
lat: mp.geometry!.geoSerie!.geoPoints[0]
|
||||
.latitude,
|
||||
lon: mp.geometry!.geoSerie!.geoPoints[0]
|
||||
.longitude);
|
||||
lat: mp.coordinates[0][1],
|
||||
lon: mp.coordinates[0][0]);
|
||||
|
||||
destinationController
|
||||
.destinationMatrixFromCurrentPoint([ds, tp]);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
@ -22,16 +22,15 @@ class _ListWidgetState extends State<ListWidget> {
|
||||
Get.find<DestinationController>();
|
||||
|
||||
Image getImage(int index) {
|
||||
if (indexController.locations[0].collection[index].properties!["photos"] ==
|
||||
if (indexController.locations[0].features[index]!.properties!["photos"] ==
|
||||
null ||
|
||||
indexController.locations[0].collection[index].properties!["photos"] ==
|
||||
indexController.locations[0].features[index]!.properties!["photos"] ==
|
||||
"") {
|
||||
return const Image(image: AssetImage('assets/images/empty_image.png'));
|
||||
} else {
|
||||
//print("==== photo index is $index ===");
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
GeoJsonFeature<dynamic> gf =
|
||||
indexController.locations[0].collection[index];
|
||||
GeoJSONFeature gf = indexController.locations[0].features[index]!;
|
||||
String photo = gf.properties!["photos"];
|
||||
return Image(
|
||||
image: NetworkImage('$serverUrl/media/compressed/$photo'),
|
||||
@ -43,7 +42,7 @@ class _ListWidgetState extends State<ListWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
void changeCurrentFeature(GeoJsonFeature fs) {
|
||||
void changeCurrentFeature(GeoJSONFeature fs) {
|
||||
if (indexController.currentFeature.isNotEmpty) {
|
||||
indexController.currentFeature.clear();
|
||||
}
|
||||
@ -55,14 +54,14 @@ class _ListWidgetState extends State<ListWidget> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Destination createDestination(GeoJsonFeature feature) {
|
||||
Destination createDestination(GeoJSONFeature feature) {
|
||||
final props = feature.properties;
|
||||
GeoJsonMultiPoint pt = feature.geometry;
|
||||
GeoJSONMultiPoint pt = feature.geometry as GeoJSONMultiPoint;
|
||||
|
||||
return Destination(
|
||||
cp: props!['cp'],
|
||||
lat: pt.geoSerie!.geoPoints.first.latitude,
|
||||
lon: pt.geoSerie!.geoPoints.first.longitude,
|
||||
lat: pt.coordinates[0][1],
|
||||
lon: pt.coordinates[0][0],
|
||||
);
|
||||
}
|
||||
|
||||
@ -72,7 +71,7 @@ class _ListWidgetState extends State<ListWidget> {
|
||||
lat: indexController.currentLat, lon: indexController.currentLon);
|
||||
//Destination dest1 = createDestination(indexController.locations[0].collection[0]);
|
||||
Destination dest2 =
|
||||
createDestination(indexController.locations[0].collection[i]);
|
||||
createDestination(indexController.locations[0].features[i]!);
|
||||
|
||||
// Get the distance between these two destinations
|
||||
final res = await MatrixService.getDestinations([desCurr, dest2]);
|
||||
@ -83,9 +82,9 @@ class _ListWidgetState extends State<ListWidget> {
|
||||
|
||||
Future<void> _pullRefresh() async {
|
||||
//print("pull to refesh");
|
||||
indexController.locations[0].collection.sort((a, b) =>
|
||||
(a.properties!['cp'] as Comparable)
|
||||
.compareTo(b.properties!['cp'] as Comparable));
|
||||
indexController.locations[0].features.sort((a, b) =>
|
||||
(a!.properties!['cp'] as Comparable)
|
||||
.compareTo(b!.properties!['cp'] as Comparable));
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@ -96,12 +95,12 @@ class _ListWidgetState extends State<ListWidget> {
|
||||
? RefreshIndicator(
|
||||
onRefresh: _pullRefresh,
|
||||
child: ListView.builder(
|
||||
itemCount: indexController.locations[0].collection.length,
|
||||
itemCount: indexController.locations[0].features.length,
|
||||
shrinkWrap: true,
|
||||
itemBuilder: (_, index) {
|
||||
bool isFound = false;
|
||||
for (Destination d in destinationController.destinations) {
|
||||
if (indexController.locations[0].collection[index]
|
||||
if (indexController.locations[0].features[index]!
|
||||
.properties!['location_id'] ==
|
||||
d.location_id) {
|
||||
isFound = true;
|
||||
@ -113,8 +112,8 @@ class _ListWidgetState extends State<ListWidget> {
|
||||
selected: isFound,
|
||||
selectedTileColor: Colors.yellow.shade200,
|
||||
onTap: () {
|
||||
GeoJsonFeature gf =
|
||||
indexController.locations[0].collection[index];
|
||||
GeoJSONFeature gf =
|
||||
indexController.locations[0].features[index]!;
|
||||
Destination des =
|
||||
destinationController.festuretoDestination(gf);
|
||||
changeCurrentFeature(gf);
|
||||
@ -129,29 +128,27 @@ class _ListWidgetState extends State<ListWidget> {
|
||||
)));
|
||||
},
|
||||
leading: getImage(index),
|
||||
title: indexController.locations[0].collection[index]
|
||||
title: indexController.locations[0].features[index]!
|
||||
.properties!['location_name'] !=
|
||||
null
|
||||
? Text(indexController.locations[0]
|
||||
.collection[index].properties!['location_name']
|
||||
? Text(indexController.locations[0].features[index]!
|
||||
.properties!['location_name']
|
||||
.toString())
|
||||
: const Text(""),
|
||||
subtitle: indexController.locations[0].collection[index]
|
||||
subtitle: indexController.locations[0].features[index]!
|
||||
.properties!['category'] !=
|
||||
null
|
||||
? Text(indexController.locations[0]
|
||||
.collection[index].properties!['category'])
|
||||
? Text(indexController.locations[0].features[index]!
|
||||
.properties!['category'])
|
||||
: const Text(""),
|
||||
trailing: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
indexController.locations[0].collection[index]
|
||||
indexController.locations[0].features[index]!
|
||||
.properties!['sub_loc_id'] !=
|
||||
null
|
||||
? Text(indexController
|
||||
.locations[0]
|
||||
.collection[index]
|
||||
.properties!['sub_loc_id'])
|
||||
? Text(indexController.locations[0]
|
||||
.features[index]!.properties!['sub_loc_id'])
|
||||
: const Text(""),
|
||||
SizedBox(
|
||||
width: 100,
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
|
||||
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
@ -25,8 +25,8 @@ class MapWidget extends StatelessWidget {
|
||||
|
||||
StreamSubscription? subscription;
|
||||
|
||||
Widget getMarkerShape(GeoJsonFeature i, BuildContext context) {
|
||||
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
|
||||
Widget getMarkerShape(GeoJSONFeature i, BuildContext context) {
|
||||
GeoJSONMultiPoint p = i.geometry as GeoJSONMultiPoint;
|
||||
//print("lat is ${p.geoSerie!.geoPoints[0].latitude} and lon is ${p.geoSerie!.geoPoints[0].longitude}");
|
||||
//RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||
return Row(
|
||||
@ -34,9 +34,8 @@ class MapWidget extends StatelessWidget {
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
GeoJsonFeature? fs = indexController.getFeatureForLatLong(
|
||||
p.geoSerie!.geoPoints[0].latitude,
|
||||
p.geoSerie!.geoPoints[0].longitude);
|
||||
GeoJSONFeature? fs = indexController.getFeatureForLatLong(
|
||||
p.coordinates[0][1], p.coordinates[0][0]);
|
||||
//print("------- fs $fs------");
|
||||
if (fs != null) {
|
||||
indexController.currentFeature.clear();
|
||||
@ -204,27 +203,24 @@ class MapWidget extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
indexController.locations.isNotEmpty &&
|
||||
indexController.locations[0].collection.isNotEmpty
|
||||
indexController.locations[0].features.isNotEmpty
|
||||
? MarkerLayer(
|
||||
markers:
|
||||
indexController.locations[0].collection.map((i) {
|
||||
indexController.locations[0].features.map((i) {
|
||||
//print("i si ${i.properties!['location_id']}");
|
||||
|
||||
RegExp regex = RegExp(r'([.]*0)(?!.*\d)');
|
||||
GeoJsonMultiPoint p =
|
||||
i.geometry as GeoJsonMultiPoint;
|
||||
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.exactly(Anchor(108.0, 18.0)),
|
||||
height: 32.0,
|
||||
width: 120.0,
|
||||
point: LatLng(p.geoSerie!.geoPoints[0].latitude,
|
||||
p.geoSerie!.geoPoints[0].longitude),
|
||||
builder: (ctx) {
|
||||
return getMarkerShape(i, context);
|
||||
},
|
||||
);
|
||||
alignment: Alignment.topCenter,
|
||||
height: 32.0,
|
||||
width: 120.0,
|
||||
point: LatLng(
|
||||
p.coordinates[0][1], p.coordinates[0][0]),
|
||||
child: getMarkerShape(i, context));
|
||||
}).toList(),
|
||||
)
|
||||
: const Center(child: CircularProgressIndicator()),
|
||||
|
||||
Reference in New Issue
Block a user