change modes
This commit is contained in:
@ -10,12 +10,14 @@ import 'package:geojson/geojson.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
//import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/services/destination_service.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_new.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
import 'package:rogapp/widgets/bread_crum_widget.dart';
|
||||
|
||||
class DestinationMapPage extends StatefulWidget {
|
||||
DestinationMapPage({ Key? key }) : super(key: key);
|
||||
@ -34,40 +36,41 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
|
||||
|
||||
|
||||
Widget examplePopup(Marker marker){
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(minWidth: 100, maxWidth: 200),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const Text(
|
||||
'Popup for a marker!',
|
||||
overflow: TextOverflow.fade,
|
||||
softWrap: false,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14.0,
|
||||
),
|
||||
),
|
||||
const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)),
|
||||
Text(
|
||||
'Position: ${marker.point.latitude}, ${marker.point.longitude}',
|
||||
style: const TextStyle(fontSize: 12.0),
|
||||
),
|
||||
Text(
|
||||
'Marker size: ${marker.width}, ${marker.height}',
|
||||
style: const TextStyle(fontSize: 12.0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
// Widget examplePopup(Marker marker){
|
||||
// return Padding(
|
||||
// padding: const EdgeInsets.all(10),
|
||||
// child: Container(
|
||||
// constraints: const BoxConstraints(minWidth: 100, maxWidth: 200),
|
||||
// color: Colors.white,
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: <Widget>[
|
||||
// const Text(
|
||||
// 'Popup for a marker!',
|
||||
// overflow: TextOverflow.fade,
|
||||
// softWrap: false,
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w500,
|
||||
// fontSize: 14.0,
|
||||
// ),
|
||||
// ),
|
||||
// const Padding(padding: EdgeInsets.symmetric(vertical: 4.0)),
|
||||
// Text(
|
||||
// 'Position: ${marker.point.latitude}, ${marker.point.longitude}',
|
||||
// style: const TextStyle(fontSize: 12.0),
|
||||
// ),
|
||||
// Text(
|
||||
// 'Marker size: ${marker.width}, ${marker.height}',
|
||||
// style: const TextStyle(fontSize: 12.0),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
|
||||
List<LatLng>? getPoints(){
|
||||
@ -82,21 +85,19 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
|
||||
List<Marker>? getMarkers() {
|
||||
List<Marker> pts = [];
|
||||
for(dynamic d in destinationController.destinations){
|
||||
double lat = d["location"]["geometry"]["coordinates"][0][1];
|
||||
double lan = d["location"]["geometry"]["coordinates"][0][0];
|
||||
for(Destination d in destinationController.destinations){
|
||||
//print("-----lat ${lat}, ----- lon ${lan}");
|
||||
Marker m = Marker(point: LatLng(lat, lan), builder:(cts){
|
||||
Marker m = Marker(point: LatLng(d.lat!, d.lon!), builder:(cts){
|
||||
//return Icon(Icons.pin_drop);
|
||||
return IconButton(
|
||||
onPressed: ()async {
|
||||
GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lan);
|
||||
Destination? fs = await destinationController.getDEstinationForLatLong(d.lat!, d.lon!);
|
||||
print("----fsf-----${fs}");
|
||||
if(fs != null){
|
||||
if(indexController.currentFeature.length > 0) {
|
||||
indexController.currentFeature.clear();
|
||||
indexController.currentDestinationFeature.clear();
|
||||
}
|
||||
indexController.currentFeature.add(fs);
|
||||
indexController.currentDestinationFeature.add(fs);
|
||||
indexController.getAction();
|
||||
|
||||
showModalBottomSheet(context: context, isScrollControlled: true,
|
||||
@ -116,8 +117,9 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
DestinationService.getDestinationLine(destinationController.destinations)?.then((value){
|
||||
print("---- loading destination points ------ ${value}");
|
||||
//print("---- loading destination points ------ ${value}");
|
||||
indexController.routePoints.clear();
|
||||
indexController.routePoints = value;
|
||||
});
|
||||
@ -127,65 +129,83 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx((() =>
|
||||
FlutterMap(
|
||||
options: MapOptions(
|
||||
onMapCreated: (c){
|
||||
indexController.rogMapController = c;
|
||||
indexController.rogMapController!.onReady.then((_) {
|
||||
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
|
||||
if (mapEvent is MapEventMoveStart) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
|
||||
// do something
|
||||
}
|
||||
if (mapEvent is MapEventMoveEnd) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] END');
|
||||
//indexController.loadLocationsBound();
|
||||
}
|
||||
});
|
||||
});
|
||||
} ,
|
||||
bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
|
||||
zoom: 1,
|
||||
maxZoom: 20,
|
||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||
plugins: [LocationMarkerPlugin(),]
|
||||
),
|
||||
children: [
|
||||
TileLayerWidget(
|
||||
options: TileLayerOptions(
|
||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
subdomains: ['a', 'b', 'c'],
|
||||
),
|
||||
),
|
||||
PolylineLayerWidget(
|
||||
options: PolylineLayerOptions(
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: getPoints()!,
|
||||
strokeWidth: 4.0,
|
||||
color: Colors.purple),
|
||||
],
|
||||
),
|
||||
),
|
||||
// PopupMarkerLayerWidget(
|
||||
// options: PopupMarkerLayerOptions(
|
||||
// popupController: _popupLayerController,
|
||||
// markers: _markers,
|
||||
// markerRotateAlignment:
|
||||
// PopupMarkerLayerOptions.rotationAlignmentFor(AnchorAlign.top),
|
||||
// popupBuilder: (BuildContext context, Marker marker) =>
|
||||
|
||||
// examplePopup(marker),
|
||||
// ),
|
||||
// ),
|
||||
MarkerLayerWidget(
|
||||
options: MarkerLayerOptions(
|
||||
markers: getMarkers()!
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
)
|
||||
Stack(
|
||||
children: [
|
||||
indexController.is_rog_mapcontroller_loaded.value == false ?
|
||||
Center(child: CircularProgressIndicator())
|
||||
:
|
||||
BreadCrumbWidget(mapController:indexController.rogMapController),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top:50.0),
|
||||
//child: TravelMap(),
|
||||
child:
|
||||
TravelMap(),
|
||||
)
|
||||
],
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
FlutterMap TravelMap() {
|
||||
return FlutterMap(
|
||||
options: MapOptions(
|
||||
onMapCreated: (c){
|
||||
indexController.rogMapController = c;
|
||||
indexController.rogMapController!.onReady.then((_) {
|
||||
indexController.is_rog_mapcontroller_loaded.value = true;
|
||||
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
|
||||
if (mapEvent is MapEventMoveStart) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] START');
|
||||
// do something
|
||||
}
|
||||
if (mapEvent is MapEventMoveEnd) {
|
||||
//print(DateTime.now().toString() + ' [MapEventMoveStart] END');
|
||||
//indexController.loadLocationsBound();
|
||||
}
|
||||
});
|
||||
});
|
||||
} ,
|
||||
bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
|
||||
zoom: 1,
|
||||
maxZoom: 20,
|
||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||
plugins: [LocationMarkerPlugin(),]
|
||||
),
|
||||
children: [
|
||||
TileLayerWidget(
|
||||
options: TileLayerOptions(
|
||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
subdomains: ['a', 'b', 'c'],
|
||||
),
|
||||
),
|
||||
PolylineLayerWidget(
|
||||
options: PolylineLayerOptions(
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: getPoints()!,
|
||||
strokeWidth: 4.0,
|
||||
color: Colors.purple),
|
||||
],
|
||||
),
|
||||
),
|
||||
// PopupMarkerLayerWidget(
|
||||
// options: PopupMarkerLayerOptions(
|
||||
// popupController: _popupLayerController,
|
||||
// markers: _markers,
|
||||
// markerRotateAlignment:
|
||||
// PopupMarkerLayerOptions.rotationAlignmentFor(AnchorAlign.top),
|
||||
// popupBuilder: (BuildContext context, Marker marker) =>
|
||||
|
||||
// examplePopup(marker),
|
||||
// ),
|
||||
// ),
|
||||
MarkerLayerWidget(
|
||||
options: MarkerLayerOptions(
|
||||
markers: getMarkers()!
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user