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

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