added location
This commit is contained in:
parent
129a021ed9
commit
4c3c279426
|
|
@ -1,6 +1,9 @@
|
||||||
// App
|
// App
|
||||||
const String appTitle = 'Durnukly ýol';
|
const String appTitle = 'Durnukly ýol';
|
||||||
|
|
||||||
|
// empty guid
|
||||||
|
const String emptyGUID = '00000000-0000-0000-0000-000000000000';
|
||||||
|
|
||||||
// Storage and Databases
|
// Storage and Databases
|
||||||
const String articlesTableName = '';
|
const String articlesTableName = '';
|
||||||
const String databaseName = '';
|
const String databaseName = '';
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
||||||
void _checkLocationStatus() {
|
void _checkLocationStatus() {
|
||||||
setState(() {
|
setState(() {
|
||||||
debugPrint('NAME: ${GoodsState.Reserved.name}');
|
debugPrint('NAME: ${GoodsState.Reserved.name}');
|
||||||
_showLocation = widget.order.state != GoodsState.Reserved.name;
|
_showLocation = widget.order.cargoId != emptyGUID;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
import 'package:cargo/core/constants/colors.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_map/flutter_map.dart';
|
import 'package:flutter_map/flutter_map.dart';
|
||||||
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
|
||||||
import 'package:latlong2/latlong.dart';
|
import 'package:latlong2/latlong.dart';
|
||||||
|
|
||||||
import '../../../application/order_detail_bloc/order_detail_bloc.dart';
|
import '../../../application/order_detail_bloc/order_detail_bloc.dart';
|
||||||
|
|
@ -21,8 +21,6 @@ class ClusteringPage extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ClusteringPageState extends State<ClusteringPage> {
|
class _ClusteringPageState extends State<ClusteringPage> {
|
||||||
final PopupController _popupController = PopupController();
|
|
||||||
|
|
||||||
late List<Marker> markers;
|
late List<Marker> markers;
|
||||||
late List<Polyline> polylines;
|
late List<Polyline> polylines;
|
||||||
|
|
||||||
|
|
@ -48,10 +46,15 @@ class _ClusteringPageState extends State<ClusteringPage> {
|
||||||
markers = state.routes.map((route) {
|
markers = state.routes.map((route) {
|
||||||
return Marker(
|
return Marker(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
height: 30,
|
height: 35,
|
||||||
width: 30,
|
width: 35,
|
||||||
point: LatLng(route.lat, route.long),
|
point: LatLng(route.lat, route.long),
|
||||||
child: const Icon(Icons.pin_drop),
|
child: Icon(
|
||||||
|
Icons.pin_drop_rounded,
|
||||||
|
color: route.isCurrent ? AppColors.primary : Colors.red,
|
||||||
|
size: 40,
|
||||||
|
),
|
||||||
|
rotate: true,
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
|
|
@ -61,81 +64,33 @@ class _ClusteringPageState extends State<ClusteringPage> {
|
||||||
points: state.routes.map((route) {
|
points: state.routes.map((route) {
|
||||||
return LatLng(route.lat, route.long);
|
return LatLng(route.lat, route.long);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
borderStrokeWidth: 6.6,
|
borderStrokeWidth: 3.5,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
borderColor: Colors.green,
|
borderColor: Colors.green,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
return PopupScope(
|
return FlutterMap(
|
||||||
popupController: _popupController,
|
options: MapOptions(
|
||||||
child: FlutterMap(
|
initialCenter: markers.isNotEmpty ? markers.first.point : const LatLng(0, 0),
|
||||||
options: MapOptions(
|
initialZoom: 4.5,
|
||||||
initialCenter:
|
maxZoom: 45,
|
||||||
markers.isNotEmpty ? markers.first.point : const LatLng(0, 0), // Default to (0, 0) if no markers
|
// onTap: (_, __) => _popupController.hideAllPopups(),
|
||||||
initialZoom: 4.5,
|
|
||||||
maxZoom: 45,
|
|
||||||
onTap: (_, __) => _popupController.hideAllPopups(),
|
|
||||||
),
|
|
||||||
children: <Widget>[
|
|
||||||
TileLayer(
|
|
||||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
||||||
subdomains: const ['a', 'b', 'c'],
|
|
||||||
),
|
|
||||||
MarkerClusterLayerWidget(
|
|
||||||
options: MarkerClusterLayerOptions(
|
|
||||||
spiderfyCircleRadius: 80,
|
|
||||||
spiderfySpiralDistanceMultiplier: 2,
|
|
||||||
circleSpiralSwitchover: 12,
|
|
||||||
maxClusterRadius: 120,
|
|
||||||
rotate: true,
|
|
||||||
size: const Size(40, 40),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
padding: const EdgeInsets.all(50),
|
|
||||||
maxZoom: 15,
|
|
||||||
markers: markers,
|
|
||||||
polygonOptions: const PolygonOptions(
|
|
||||||
borderColor: Colors.blueAccent,
|
|
||||||
color: Colors.black12,
|
|
||||||
borderStrokeWidth: 3,
|
|
||||||
),
|
|
||||||
popupOptions: PopupOptions(
|
|
||||||
popupSnap: PopupSnap.markerTop,
|
|
||||||
popupController: _popupController,
|
|
||||||
popupBuilder: (_, marker) => Container(
|
|
||||||
width: 200,
|
|
||||||
height: 100,
|
|
||||||
color: Colors.white,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () => debugPrint('Popup tap!'),
|
|
||||||
child: const Text(
|
|
||||||
'Container popup for marker',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
builder: (context, markers) {
|
|
||||||
return Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
markers.length.toString(),
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PolylineLayer(
|
|
||||||
polylineCulling: true,
|
|
||||||
polylines: polylines,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
children: <Widget>[
|
||||||
|
TileLayer(
|
||||||
|
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
subdomains: const ['a', 'b', 'c'],
|
||||||
|
),
|
||||||
|
PolylineLayer(
|
||||||
|
polylineCulling: true,
|
||||||
|
polylines: polylines,
|
||||||
|
),
|
||||||
|
MarkerLayer(
|
||||||
|
alignment: Alignment.topCenter,
|
||||||
|
markers: markers,
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
} else if (state is RoutesError) {
|
} else if (state is RoutesError) {
|
||||||
return Center(
|
return Center(
|
||||||
|
|
@ -149,155 +104,3 @@ class _ClusteringPageState extends State<ClusteringPage> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* class ClusteringPage extends StatefulWidget {
|
|
||||||
static const String route = 'clusteringPage';
|
|
||||||
|
|
||||||
const ClusteringPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ClusteringPage> createState() => _ClusteringPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ClusteringPageState extends State<ClusteringPage> {
|
|
||||||
final PopupController _popupController = PopupController();
|
|
||||||
|
|
||||||
late List<Marker> markers;
|
|
||||||
late int pointIndex;
|
|
||||||
List<LatLng> points = [
|
|
||||||
const LatLng(37.90970, 58.39795),
|
|
||||||
const LatLng(37.90491, 58.39742),
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
pointIndex = 0;
|
|
||||||
markers = [
|
|
||||||
Marker(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
height: 30,
|
|
||||||
width: 30,
|
|
||||||
point: points[pointIndex],
|
|
||||||
child: const Icon(Icons.pin_drop),
|
|
||||||
),
|
|
||||||
const Marker(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
height: 30,
|
|
||||||
width: 30,
|
|
||||||
point: LatLng(49.8566, 3.3522),
|
|
||||||
child: Icon(Icons.pin_drop),
|
|
||||||
),
|
|
||||||
const Marker(
|
|
||||||
alignment: Alignment.center,
|
|
||||||
height: 30,
|
|
||||||
width: 30,
|
|
||||||
point: LatLng(49.8566, 3.3522),
|
|
||||||
child: Icon(Icons.pin_drop),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: () {
|
|
||||||
pointIndex++;
|
|
||||||
if (pointIndex >= points.length) {
|
|
||||||
pointIndex = 0;
|
|
||||||
}
|
|
||||||
setState(() {
|
|
||||||
markers[0] = Marker(
|
|
||||||
point: points[pointIndex],
|
|
||||||
alignment: Alignment.center,
|
|
||||||
height: 30,
|
|
||||||
width: 30,
|
|
||||||
child: const Icon(Icons.pin_drop),
|
|
||||||
);
|
|
||||||
markers = List.from(markers);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: const Icon(Icons.refresh),
|
|
||||||
),
|
|
||||||
body: PopupScope(
|
|
||||||
popupController: _popupController,
|
|
||||||
child: FlutterMap(
|
|
||||||
options: MapOptions(
|
|
||||||
initialCenter: points[0],
|
|
||||||
initialZoom: 4.5,
|
|
||||||
maxZoom: 45,
|
|
||||||
onTap: (_, __) => _popupController.hideAllPopups(), // Hide popup when the map is tapped.
|
|
||||||
),
|
|
||||||
children: <Widget>[
|
|
||||||
TileLayer(
|
|
||||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
||||||
subdomains: const ['a', 'b', 'c'],
|
|
||||||
),
|
|
||||||
MarkerClusterLayerWidget(
|
|
||||||
options: MarkerClusterLayerOptions(
|
|
||||||
spiderfyCircleRadius: 80,
|
|
||||||
spiderfySpiralDistanceMultiplier: 2,
|
|
||||||
circleSpiralSwitchover: 12,
|
|
||||||
maxClusterRadius: 120,
|
|
||||||
rotate: true,
|
|
||||||
size: const Size(40, 40),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
padding: const EdgeInsets.all(50),
|
|
||||||
maxZoom: 15,
|
|
||||||
markers: markers,
|
|
||||||
polygonOptions: const PolygonOptions(
|
|
||||||
borderColor: Colors.blueAccent,
|
|
||||||
color: Colors.black12,
|
|
||||||
borderStrokeWidth: 3,
|
|
||||||
),
|
|
||||||
popupOptions: PopupOptions(
|
|
||||||
popupSnap: PopupSnap.markerTop,
|
|
||||||
popupController: _popupController,
|
|
||||||
popupBuilder: (_, marker) => Container(
|
|
||||||
width: 200,
|
|
||||||
height: 100,
|
|
||||||
color: Colors.white,
|
|
||||||
child: GestureDetector(
|
|
||||||
onTap: () => debugPrint('Popup tap!'),
|
|
||||||
child: const Text(
|
|
||||||
'Container popup for marker',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
builder: (context, markers) {
|
|
||||||
return Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(20),
|
|
||||||
color: Colors.blue,
|
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
markers.length.toString(),
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
PolylineLayer(
|
|
||||||
polylineCulling: true,
|
|
||||||
polylines: [
|
|
||||||
Polyline(
|
|
||||||
points: [const LatLng(37.90970, 58.39795), const LatLng(37.90491, 58.39742)],
|
|
||||||
borderStrokeWidth: 6.6,
|
|
||||||
color: Colors.red,
|
|
||||||
borderColor: Colors.green,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_map/flutter_map.dart';
|
|
||||||
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
|
||||||
import 'package:latlong2/latlong.dart';
|
|
||||||
|
|
||||||
class ClusteringManyMarkersPage extends StatefulWidget {
|
|
||||||
static const String route = 'clusteringManyMarkersPage';
|
|
||||||
|
|
||||||
const ClusteringManyMarkersPage({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<ClusteringManyMarkersPage> createState() => _ClusteringManyMarkersPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ClusteringManyMarkersPageState extends State<ClusteringManyMarkersPage> {
|
|
||||||
static const totalMarkers = 2000.0;
|
|
||||||
final minLatLng = const LatLng(49.8566, 1.3522);
|
|
||||||
final maxLatLng = const LatLng(58.3498, -10.2603);
|
|
||||||
|
|
||||||
late List<Marker> markers;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
final latitudeRange = maxLatLng.latitude - minLatLng.latitude;
|
|
||||||
final longitudeRange = maxLatLng.longitude - minLatLng.longitude;
|
|
||||||
|
|
||||||
final stepsInEachDirection = sqrt(totalMarkers).floor();
|
|
||||||
final latStep = latitudeRange / stepsInEachDirection;
|
|
||||||
final lonStep = longitudeRange / stepsInEachDirection;
|
|
||||||
|
|
||||||
markers = [];
|
|
||||||
for (var i = 0; i < stepsInEachDirection; i++) {
|
|
||||||
for (var j = 0; j < stepsInEachDirection; j++) {
|
|
||||||
final latLng = LatLng(
|
|
||||||
minLatLng.latitude + i * latStep,
|
|
||||||
minLatLng.longitude + j * lonStep,
|
|
||||||
);
|
|
||||||
|
|
||||||
markers.add(
|
|
||||||
Marker(
|
|
||||||
height: 30,
|
|
||||||
width: 30,
|
|
||||||
point: latLng,
|
|
||||||
child: const Icon(Icons.pin_drop),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(title: const Text('Clustering Many Markers Page')),
|
|
||||||
body: FlutterMap(
|
|
||||||
options: MapOptions(
|
|
||||||
initialCenter:
|
|
||||||
LatLng((maxLatLng.latitude + minLatLng.latitude) / 2, (maxLatLng.longitude + minLatLng.longitude) / 2),
|
|
||||||
initialZoom: 6,
|
|
||||||
maxZoom: 15,
|
|
||||||
),
|
|
||||||
children: <Widget>[
|
|
||||||
TileLayer(
|
|
||||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
||||||
subdomains: const ['a', 'b', 'c'],
|
|
||||||
),
|
|
||||||
MarkerClusterLayerWidget(
|
|
||||||
options: MarkerClusterLayerOptions(
|
|
||||||
maxClusterRadius: 45,
|
|
||||||
size: const Size(40, 40),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
padding: const EdgeInsets.all(50),
|
|
||||||
maxZoom: 15,
|
|
||||||
markers: markers,
|
|
||||||
builder: (context, markers) {
|
|
||||||
return Container(
|
|
||||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: Colors.blue),
|
|
||||||
child: Center(
|
|
||||||
child: Text(
|
|
||||||
markers.length.toString(),
|
|
||||||
style: const TextStyle(color: Colors.white),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
24
pubspec.lock
24
pubspec.lock
|
|
@ -1,14 +1,6 @@
|
||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
animated_stack_widget:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: animated_stack_widget
|
|
||||||
sha256: ce4788dd158768c9d4388354b6fb72600b78e041a37afc4c279c63ecafcb9408
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.0.4"
|
|
||||||
args:
|
args:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -163,22 +155,6 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.2.1"
|
version: "6.2.1"
|
||||||
flutter_map_marker_cluster:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flutter_map_marker_cluster
|
|
||||||
sha256: a324f48da5ee83a3f29fd8d08b4b1e6e3114ff5c6cab910124d6a2e1f06f08cc
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.6"
|
|
||||||
flutter_map_marker_popup:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: flutter_map_marker_popup
|
|
||||||
sha256: ec563bcbae24a18ac16815fb75ac5ab33ccba609e14db70e252a67de19c6639c
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "6.1.2"
|
|
||||||
flutter_phoenix:
|
flutter_phoenix:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ dependencies:
|
||||||
flutter_svg: ^2.0.10+1
|
flutter_svg: ^2.0.10+1
|
||||||
flutter_map: ">=6.0.0 <7.0.0"
|
flutter_map: ">=6.0.0 <7.0.0"
|
||||||
latlong2: ^0.9.0
|
latlong2: ^0.9.0
|
||||||
flutter_map_marker_cluster: ^1.3.6
|
# flutter_map_marker_cluster: ^1.3.6
|
||||||
easy_localization: ^3.0.7
|
easy_localization: ^3.0.7
|
||||||
intl: ^0.19.0
|
intl: ^0.19.0
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue