initial rod app
This commit is contained in:
0
lib/pages/map/map_controller.dart
Normal file
0
lib/pages/map/map_controller.dart
Normal file
136
lib/pages/map/map_page.dart
Normal file
136
lib/pages/map/map_page.dart
Normal file
@ -0,0 +1,136 @@
|
||||
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:geojson/geojson.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_state_manager/get_state_manager.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:rogapp/pages/drawer/drawer_page.dart';
|
||||
import 'package:rogapp/pages/home/home_controller.dart';
|
||||
import 'package:flutter_map_marker_cluster/flutter_map_marker_cluster.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'package:rogapp/widgets/base_layer_widget.dart';
|
||||
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
|
||||
|
||||
|
||||
class MapPage extends StatelessWidget {
|
||||
MapPage({ Key? key }) : super(key: key);
|
||||
|
||||
final HomeController homeController = Get.find<HomeController>();
|
||||
|
||||
final MapController mapController = MapController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final PopupController _popupController = PopupController();
|
||||
|
||||
|
||||
return Scaffold(
|
||||
drawer: DrawerPage(),
|
||||
appBar: AppBar(
|
||||
title: Text("app_title".tr),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.map),
|
||||
onPressed: () => {print("action")},
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
child: new Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Expanded(child: IconButton(icon: Icon(Icons.camera_enhance), onPressed: (){},),),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.arrow_back_ios), onPressed: (){}),),
|
||||
Expanded(child: new Text('')),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.arrow_forward_ios), onPressed: (){}),),
|
||||
Expanded(child: IconButton(icon: Icon(Icons.travel_explore), onPressed: (){}),),
|
||||
],
|
||||
),
|
||||
),
|
||||
floatingActionButton: new FloatingActionButton(
|
||||
onPressed: (){
|
||||
Get.toNamed(AppPages.INITIAL);
|
||||
},
|
||||
tooltip: 'Increment',
|
||||
child: new Icon(Icons.document_scanner),
|
||||
elevation: 4.0,
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
body: SafeArea(
|
||||
child: Obx(() =>
|
||||
Stack(
|
||||
children: [
|
||||
FlutterMap(
|
||||
mapController: mapController,
|
||||
options: MapOptions(
|
||||
center: LatLng(37.15319600454702, 139.58765950528198),
|
||||
zoom: 6,
|
||||
maxZoom: 20,
|
||||
plugins: [
|
||||
MarkerClusterPlugin(),
|
||||
],
|
||||
onTap: (_, __) =>
|
||||
_popupController
|
||||
.hideAllPopups(), // Hide popup when the map is tapped.
|
||||
),
|
||||
children: [
|
||||
BaseLayer(),
|
||||
LocationMarkerLayerWidget(),
|
||||
homeController.locations.length > 0 ?
|
||||
MarkerClusterLayerWidget(
|
||||
options: MarkerClusterLayerOptions(
|
||||
spiderfyCircleRadius: 80,
|
||||
spiderfySpiralDistanceMultiplier: 2,
|
||||
circleSpiralSwitchover: 12,
|
||||
maxClusterRadius: 20,
|
||||
rotate: true,
|
||||
onMarkerTap: (marker) => showModalBottomSheet(
|
||||
isScrollControlled: true,
|
||||
context: context,
|
||||
builder: (context) => BottomSheetWidget(pt: homeController.getFeatureForLatLong(marker.point.latitude, marker.point.longitude),),
|
||||
),
|
||||
size: Size(40, 40),
|
||||
anchor: AnchorPos.align(AnchorAlign.center),
|
||||
fitBoundsOptions: const FitBoundsOptions(
|
||||
padding: EdgeInsets.all(50),
|
||||
maxZoom: 15,
|
||||
),
|
||||
markers:homeController.locations[0].collection.map((i) {
|
||||
GeoJsonMultiPoint p = i.geometry as GeoJsonMultiPoint;
|
||||
return Marker(
|
||||
anchorPos: AnchorPos.align(AnchorAlign.center),
|
||||
height: 70.0,
|
||||
width: 70.0,
|
||||
point: LatLng(p.geoSerie!.geoPoints[0].latitude, p.geoSerie!.geoPoints[0].longitude),
|
||||
builder: (ctx) => Icon(Icons.pin_drop),
|
||||
);
|
||||
}).toList(),
|
||||
builder: (context, markers) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20.0),
|
||||
color: Colors.blue),
|
||||
child: Center(
|
||||
child: Text(
|
||||
markers.length.toString(),
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
): Container(height:0,width: 0),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user