map updated to 6

This commit is contained in:
2023-12-06 11:16:17 +05:30
parent 8d1c84d9fb
commit fa0587178f
19 changed files with 631 additions and 596 deletions

View File

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

View File

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

View File

@ -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]);

View File

@ -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,

View File

@ -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()),