update
This commit is contained in:
@ -4,7 +4,9 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/plugin_api.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';
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
@ -12,10 +14,12 @@ 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_widget.dart';
|
||||
|
||||
class DestinationMapPage extends StatefulWidget {
|
||||
DestinationMapPage({ Key? key }) : super(key: key);
|
||||
|
||||
|
||||
@override
|
||||
State<DestinationMapPage> createState() => _DestinationMapPageState();
|
||||
}
|
||||
@ -25,6 +29,69 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
|
||||
final DestinationController destinationController = Get.find<DestinationController>();
|
||||
StreamSubscription? subscription;
|
||||
final PopupController _popupLayerController = PopupController();
|
||||
|
||||
|
||||
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
final List<LatLng> _markerPositions = [
|
||||
LatLng(35.728728732933455, 137.06878077038706),
|
||||
LatLng(35.958218259568305, 137.06187578986646),
|
||||
LatLng(35.76795686324816, 137.08949571194879),
|
||||
];
|
||||
|
||||
|
||||
|
||||
List<Marker> get _markers => _markerPositions
|
||||
.map(
|
||||
(markerPosition) => Marker(
|
||||
point: markerPosition,
|
||||
width: 40,
|
||||
height: 40,
|
||||
builder: (_) => const Icon(Icons.location_on, size: 40),
|
||||
anchorPos: AnchorPos.align(AnchorAlign.top),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
|
||||
|
||||
List<LatLng>? getPoints(){
|
||||
//print("##### --- route point ${indexController.routePoints.length}");
|
||||
@ -36,14 +103,34 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
return pts;
|
||||
}
|
||||
|
||||
List<Marker>? getMarkers(){
|
||||
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];
|
||||
//print("-----lat ${lat}, ----- lon ${lan}");
|
||||
Marker m = Marker(point: LatLng(lat, lan), builder:(cts){
|
||||
return Icon(Icons.pin_drop);
|
||||
//return Icon(Icons.pin_drop);
|
||||
return IconButton(
|
||||
onPressed: ()async {
|
||||
GeoJsonFeature? fs = await destinationController.getDEstinationForLatLong(lat, lan);
|
||||
print("----fsf-----${fs}");
|
||||
if(fs != null){
|
||||
if(indexController.currentFeature.length > 0) {
|
||||
indexController.currentFeature.clear();
|
||||
}
|
||||
indexController.currentFeature.add(fs);
|
||||
indexController.getAction();
|
||||
|
||||
showModalBottomSheet(context: context, isScrollControlled: true,
|
||||
builder:((context) => BottomSheetWidget())
|
||||
);
|
||||
}
|
||||
},
|
||||
icon: Icon(Icons.pin_drop));
|
||||
|
||||
});
|
||||
|
||||
pts.add(m);
|
||||
}
|
||||
return pts;
|
||||
@ -85,15 +172,15 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
|
||||
plugins: [LocationMarkerPlugin(),]
|
||||
),
|
||||
layers: [
|
||||
TileLayerOptions(
|
||||
urlTemplate:
|
||||
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
subdomains: ['a', 'b', 'c']),
|
||||
MarkerLayerOptions(
|
||||
markers: getMarkers()!,
|
||||
children: [
|
||||
TileLayerWidget(
|
||||
options: TileLayerOptions(
|
||||
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
subdomains: ['a', 'b', 'c'],
|
||||
),
|
||||
),
|
||||
PolylineLayerOptions(
|
||||
PolylineLayerWidget(
|
||||
options: PolylineLayerOptions(
|
||||
polylines: [
|
||||
Polyline(
|
||||
points: getPoints()!,
|
||||
@ -101,8 +188,25 @@ class _DestinationMapPageState extends State<DestinationMapPage> {
|
||||
color: Colors.purple),
|
||||
],
|
||||
),
|
||||
LocationMarkerLayerOptions(),
|
||||
),
|
||||
// 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