From 0df63654db661b203b9d5d2ec92316c1a067e705 Mon Sep 17 00:00:00 2001 From: "bm.abir" Date: Mon, 20 Apr 2020 21:39:31 +0600 Subject: [PATCH 1/4] Location Name can be added and updated --- lib/menu.dart | 1 + lib/ui/infectedMapPage.dart | 86 +++++++++++++++++++++++++++++-------- 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/lib/menu.dart b/lib/menu.dart index c23a162..0b181fa 100644 --- a/lib/menu.dart +++ b/lib/menu.dart @@ -52,6 +52,7 @@ class _MenuPageState extends State{ ), backgroundColor: Colors.green[800], ), + resizeToAvoidBottomInset: true, body: Center( child: [ ReliefMapPage(currentPosition:_currentPosition), diff --git a/lib/ui/infectedMapPage.dart b/lib/ui/infectedMapPage.dart index affcfd8..fefa16e 100644 --- a/lib/ui/infectedMapPage.dart +++ b/lib/ui/infectedMapPage.dart @@ -29,6 +29,7 @@ class _InfectedMapPageState extends State{ var selectedLocationID; var selectedLocationQuantity; var selectedLocationMarkerId; + String selectedLocationName; bool loginStatus; @@ -75,6 +76,7 @@ class _InfectedMapPageState extends State{ setState(() { selectedLocationID = null; selectedLocationQuantity = null; + selectedLocationName = null; }); }, ): @@ -85,7 +87,7 @@ class _InfectedMapPageState extends State{ Padding( padding: const EdgeInsets.all(20.0), child: Align( - alignment: Alignment.bottomRight, + alignment: Alignment.bottomCenter, child:FloatingActionButton.extended( onPressed: () { if (loginStatus && email!=null){ @@ -111,14 +113,18 @@ class _InfectedMapPageState extends State{ ), ), (selectedLocationID != null && loginStatus) ? Padding( - padding: const EdgeInsets.all(20.0), + padding: const EdgeInsets.fromLTRB(0, 0, 0, 80), child: Align( - alignment: Alignment.bottomLeft, + alignment: Alignment.bottomCenter, child:FloatingActionButton.extended( onPressed: () { - _showQuantityModal(context,selectedLocationID,selectedLocationQuantity,selectedLocationMarkerId); + if(email == adminEmail){ + _showQuantityModal(context,selectedLocationID,selectedLocationQuantity,selectedLocationName,selectedLocationMarkerId); + }else{ + _showDialog("Admin Permission needed"); + } }, - label: Text('Update: $selectedLocationQuantity'), + label: Text('Update: $selectedLocationName'), icon: Icon(Icons.edit), backgroundColor: Colors.yellow[800], ), @@ -149,8 +155,9 @@ class _InfectedMapPageState extends State{ _lastMapPosition = position.target; } // ------------------- View Functions ------------------------ - void _addMarker(orgName,quantity,dataType,location,Timestamp timestamp,[documentID]) { + void _addMarker(orgName,quantity,String locationName,dataType,location,Timestamp timestamp,[documentID]) { quantity=quantity.toString(); + locationName=locationName.toString(); var date = timestamp.toDate(); var dateString = date.toString(); if(location == null){ @@ -163,7 +170,7 @@ class _InfectedMapPageState extends State{ markerId: MarkerId(location.toString()), position: location, infoWindow: InfoWindow( - title: 'Data Source: $orgName, Entry: $dataType' , + title: 'Location: $locationName Data Source: $orgName, Entry: $dataType' , snippet: ' Number of infected: $quantity ,Date: $dateString', ), icon: BitmapDescriptor.defaultMarkerWithHue(20), @@ -171,6 +178,7 @@ class _InfectedMapPageState extends State{ setState(() { selectedLocationID = documentID; selectedLocationQuantity = quantity; + selectedLocationName = locationName; selectedLocationMarkerId = location; }); @@ -204,19 +212,53 @@ class _InfectedMapPageState extends State{ }); } - _showQuantityModal(context,[updateLocationID,updateLocationQuantity,updateLocationMarkerId] ){ + _showQuantityModal(context,[updateLocationID,updateLocationQuantity,String updateLocationName,updateLocationMarkerId] ){ final _formKey = GlobalKey(); int _quantity; - showModalBottomSheet(context: context, + String _locationName; + if(updateLocationID != null){ + _quantity=int.parse(updateLocationQuantity); + _locationName=updateLocationName; + } + showModalBottomSheet(context: context, + isScrollControlled: true, builder: (context)=> Container( color: Colors.red[50], - height: 180, + height: 380, child:Stack( children: [ Form( key: _formKey, child: Column( children: [ + Padding( + padding: const EdgeInsets.all(10.0), + child:Align( + alignment: Alignment.topCenter, + child: TextFormField( + initialValue: updateLocationName, + decoration: const InputDecoration( + hintText: 'Enter new Location Name', + icon: Icon(Icons.add_location), + ), + keyboardType: TextInputType.text, + inputFormatters: [ + ], + validator: (value) { + if (value.isEmpty) { + return 'Please enter name for this location'; + } + return null; + }, + onChanged: (value){ + setState(() { + // _quantity = int.parse(updateLocationQuantity); + _locationName = value; + }); + }, + ), + ), + ), Padding( padding: const EdgeInsets.all(10.0), child:Align( @@ -240,13 +282,14 @@ class _InfectedMapPageState extends State{ onChanged: (value){ setState(() { _quantity = int.parse(value); + // _locationName = updateLocationName; }); }, ), ), ), Padding( - padding: const EdgeInsets.symmetric(vertical: 25.0,horizontal: 140.0), + padding: const EdgeInsets.symmetric(vertical: 55.0,horizontal: 140.0), child:Align( alignment: Alignment.center, child: RaisedButton.icon( @@ -265,20 +308,21 @@ class _InfectedMapPageState extends State{ if (_formKey.currentState.validate()) { // Process data. if(updateLocationID == null){ - createInfectedRecord("IEDCR",_quantity,"manual"); - _addMarker("IEDCR",_quantity,"manual",null,Timestamp.now()); + createInfectedRecord("IEDCR",_quantity,_locationName,"manual"); + _addMarker("IEDCR",_quantity,_locationName,"manual",null,Timestamp.now()); _addHeatmap(_quantity,null); }else{ print("record updated"); - updateInfectedRecord(updateLocationID,_quantity); + updateInfectedRecord(updateLocationID,_quantity,_locationName); setState(() { selectedLocationQuantity = null; + selectedLocationName = null; selectedLocationID = null; _markers.removeWhere((m) { return m.markerId.value == updateLocationMarkerId.toString(); }); }); - _addMarker("IEDCR",_quantity,"manual",null,Timestamp.now()); + _addMarker("IEDCR",_quantity,_locationName,"manual",null,Timestamp.now()); } Navigator.pop(context); } @@ -332,24 +376,28 @@ class _InfectedMapPageState extends State{ }); } // reference https://medium.com/@atul.sharma_94062/how-to-use-cloud-firestore-with-flutter-e6f9e8821b27 - void createInfectedRecord(name,quantity,dataType) async { + void createInfectedRecord(name,quantity,locationName,dataType) async { Timestamp time = Timestamp.now(); CollectionReference reliefCollection = databaseReference.collection("infected"); await reliefCollection.document().setData({ 'name': name, 'quantity': quantity, + 'location_name' : locationName, 'location': GeoPoint(_lastMapPosition.latitude,_lastMapPosition.longitude), 'data_type':dataType, 'time':time, 'submitted_by':email }); } - void updateInfectedRecord(documentId,quantity) { + void updateInfectedRecord(documentId,quantity,locationName) { try { databaseReference .collection('infected') .document('$documentId') - .updateData({'quantity': quantity}); + .updateData({ + 'quantity': quantity, + 'location_name':locationName, + }); } catch (e) { print(e.toString()); } @@ -364,7 +412,7 @@ class _InfectedMapPageState extends State{ // Ref https://fireship.io/lessons/flutter-realtime-geolocation-firebase/ GeoPoint pos = f.data['location']; LatLng latLng = new LatLng(pos.latitude, pos.longitude); - _addMarker(f.data['name'],f.data['quantity'],f.data['data_type'],latLng,f.data['time'],f.documentID); + _addMarker(f.data['name'],f.data['quantity'],f.data['location_name'],f.data['data_type'],latLng,f.data['time'],f.documentID); _addHeatmap(f.data['quantity'],latLng); }); From 24fcfeeb7f22f54fa48f573cfb655496165f3b66 Mon Sep 17 00:00:00 2001 From: "bm.abir" Date: Thu, 23 Apr 2020 06:48:55 +0600 Subject: [PATCH 2/4] google place search complete for relief map --- lib/ui/reliefMapPage.dart | 104 +++++++++++++++++++++++++++++++++++++- pubspec.lock | 21 ++++++++ pubspec.yaml | 1 + 3 files changed, 124 insertions(+), 2 deletions(-) diff --git a/lib/ui/reliefMapPage.dart b/lib/ui/reliefMapPage.dart index 7db3c02..d831d95 100644 --- a/lib/ui/reliefMapPage.dart +++ b/lib/ui/reliefMapPage.dart @@ -6,6 +6,14 @@ import 'package:google_maps_flutter_heatmap/google_maps_flutter_heatmap.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:tran_dao/common/sign_in.dart'; +import 'package:google_maps_webservice/places.dart'; +import 'package:flutter_google_places/flutter_google_places.dart'; + +const kGoogleApiKey = "AIzaSyCwWKjMQk8L2Yx32UK74chWD38AmBAy7fo"; + +// to get places detail (lat/lng) +GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: kGoogleApiKey); + class ReliefMapPage extends StatefulWidget{ final Position currentPosition; ReliefMapPage({this.currentPosition}); @@ -13,7 +21,6 @@ class ReliefMapPage extends StatefulWidget{ @override _ReliefMapPageState createState() => _ReliefMapPageState(currentPosition : currentPosition); } - class _ReliefMapPageState extends State{ Position _currentPosition; var currentPosition; @@ -55,6 +62,7 @@ class _ReliefMapPageState extends State{ return Stack( children:[ + _currentPosition != null ? GoogleMap( onMapCreated: _onMapCreated, myLocationEnabled: true, @@ -70,6 +78,57 @@ class _ReliefMapPageState extends State{ Center( child: CircularProgressIndicator(), ), + Padding(padding: const EdgeInsets.all(10), + child: Align( + alignment: Alignment.topCenter, + + child:Container( + color: Colors.white, + child:Row( + children: [ + IconButton( + splashColor: Colors.grey, + icon: Icon(Icons.menu), + onPressed: (){}, + ), + Expanded( + // child: TextField( + // cursorColor: Colors.black, + // // keyboardType: TextInputType.text, + // // textInputAction: TextInputAction.go, + // onTap: _handleSearch, + // decoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: + // EdgeInsets.symmetric(horizontal: 15), + // hintText: "Search..."), + // ), + child: FlatButton( + onPressed: _handleSearch, + child: Text("Place Search"), + ), + ), + !loginStatus ? Padding( + padding: const EdgeInsets.only(right: 8.0), + child: CircleAvatar( + backgroundColor: Colors.deepPurple, + child: Text('G'), + ), + ): + Padding( + padding: const EdgeInsets.only(right: 8.0), + child: CircleAvatar( + // backgroundColor: Colors.deepPurple, + backgroundImage: NetworkImage( + imageUrl + ), + ), + ), + ], + ), + ), + ), + ), // Ref: https://api.flutter.dev/flutter/material/FloatingActionButton-class.html#material.FloatingActionButton.2 Padding( padding: const EdgeInsets.all(20.0), @@ -164,7 +223,8 @@ class _ReliefMapPageState extends State{ _showQuantityModal(context){ final _formKey = GlobalKey(); int _quantity; - showModalBottomSheet(context: context, + showModalBottomSheet(context: context, + isScrollControlled: true, builder: (context)=> Container( color: Colors.red[50], height: 180, @@ -292,5 +352,45 @@ class _ReliefMapPageState extends State{ WeightedLatLng _createWeightedLatLng(double lat, double lng, int weight) { return WeightedLatLng(point: LatLng(lat, lng), intensity: weight); } + + + // https://pub.dev/packages/flutter_google_places#-example-tab- + void _handleSearch(){ + // show input autocomplete with selected mode + // then get the Prediction selected + PlacesAutocomplete.show( + context: context, + apiKey: kGoogleApiKey, + onError: onSearchError, + mode: Mode.overlay, + region: "bd", + language: "en", + // components: [Component(Component.country, "en")], + ).then((p){ + print("place id $p.placeId"); + displayPrediction(p); + }); + } + void onSearchError(PlacesAutocompleteResponse response) { + Scaffold.of(context).showSnackBar( + SnackBar(content: Text(response.errorMessage)), + ); + } + Future displayPrediction(Prediction p) async { + if (p != null) { + // get detail (lat/lng) + PlacesDetailsResponse detail = await _places.getDetailsByPlaceId(p.placeId); + final lat = detail.result.geometry.location.lat; + final lng = detail.result.geometry.location.lng; + print(detail.result.name); + LatLng searchedLatLng = LatLng(lat, lng); + mapController.moveCamera(CameraUpdate.newLatLng(searchedLatLng)); + Scaffold.of(context).showSnackBar( + SnackBar(content: Text("${p.description} - $lat/$lng")), + ); + } } +} + + diff --git a/pubspec.lock b/pubspec.lock index 452b40e..3229995 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -183,6 +183,13 @@ packages: url: "git://github.com/rushio-consulting/flutter_camera_ml_vision.git" source: git version: "2.2.5" + flutter_google_places: + dependency: "direct main" + description: + name: flutter_google_places + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.4" flutter_launcher_icons: dependency: "direct main" description: @@ -228,6 +235,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.1+1" + google_maps_webservice: + dependency: transitive + description: + name: google_maps_webservice + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.16" google_sign_in: dependency: "direct main" description: @@ -368,6 +382,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.5" + rxdart: + dependency: transitive + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.23.1" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 9ddccb2..d199a80 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,6 +32,7 @@ dependencies: flutter_launcher_icons: ^0.7.3 firebase_auth: ^0.15.5+3 google_sign_in: ^4.4.1 + flutter_google_places: ^0.2.4 # flutter_camera_ml_vision: ^2.2.5 flutter_camera_ml_vision: git: From 0527a542058f7c4531fa9f5ea670b391ccb35af8 Mon Sep 17 00:00:00 2001 From: "bm.abir" Date: Sat, 25 Apr 2020 05:00:14 +0600 Subject: [PATCH 3/4] save location_name in db found from lat lng , allow user edit. minor bug fix for search bar. --- lib/ui/reliefMapPage.dart | 206 +++++++++++++++++++++++--------------- 1 file changed, 128 insertions(+), 78 deletions(-) diff --git a/lib/ui/reliefMapPage.dart b/lib/ui/reliefMapPage.dart index d831d95..f50ebbb 100644 --- a/lib/ui/reliefMapPage.dart +++ b/lib/ui/reliefMapPage.dart @@ -33,7 +33,7 @@ class _ReliefMapPageState extends State{ final databaseReference = Firestore.instance; bool loginStatus=false; - + var searchTextController=TextEditingController(text: ''); void _onMapCreated(GoogleMapController controller) { @@ -59,54 +59,52 @@ class _ReliefMapPageState extends State{ @override Widget build(BuildContext context) { - return - Stack( - children:[ - - _currentPosition != null ? GoogleMap( - onMapCreated: _onMapCreated, - myLocationEnabled: true, - myLocationButtonEnabled: true, - initialCameraPosition: CameraPosition( - target: LatLng(_currentPosition.latitude,_currentPosition.longitude), - zoom: 11.0, - ), - markers: _markers, - heatmaps: _heatmaps, - onCameraMove: _onCameraMove, - ): - Center( - child: CircularProgressIndicator(), - ), - Padding(padding: const EdgeInsets.all(10), - child: Align( - alignment: Alignment.topCenter, + + return + Stack( + children:[ - child:Container( - color: Colors.white, - child:Row( - children: [ - IconButton( - splashColor: Colors.grey, - icon: Icon(Icons.menu), - onPressed: (){}, - ), - Expanded( - // child: TextField( - // cursorColor: Colors.black, - // // keyboardType: TextInputType.text, - // // textInputAction: TextInputAction.go, - // onTap: _handleSearch, - // decoration: InputDecoration( - // border: InputBorder.none, - // contentPadding: - // EdgeInsets.symmetric(horizontal: 15), - // hintText: "Search..."), - // ), - child: FlatButton( - onPressed: _handleSearch, - child: Text("Place Search"), + _currentPosition != null ? GoogleMap( + onMapCreated: _onMapCreated, + myLocationEnabled: true, + myLocationButtonEnabled: true, + initialCameraPosition: CameraPosition( + target: LatLng(_currentPosition.latitude,_currentPosition.longitude), + zoom: 11.0, + ), + markers: _markers, + heatmaps: _heatmaps, + onCameraMove: _onCameraMove, + ): + Center( + child: CircularProgressIndicator(), + ), + Padding(padding: const EdgeInsets.all(10), + child: Align( + alignment: Alignment.topCenter, + + child:Container( + color: Colors.white, + child:Row( + children: [ + IconButton( + splashColor: Colors.grey, + icon: Icon(Icons.menu), + onPressed: (){}, ), + Expanded( + child: TextField( + cursorColor: Colors.black, + controller: searchTextController, + onChanged: (val){ + _handleSearch(val); + }, + decoration: InputDecoration( + border: InputBorder.none, + contentPadding: + EdgeInsets.symmetric(horizontal: 15), + hintText: "Search..."), + ), ), !loginStatus ? Padding( padding: const EdgeInsets.only(right: 8.0), @@ -118,7 +116,6 @@ class _ReliefMapPageState extends State{ Padding( padding: const EdgeInsets.only(right: 8.0), child: CircleAvatar( - // backgroundColor: Colors.deepPurple, backgroundImage: NetworkImage( imageUrl ), @@ -137,7 +134,8 @@ class _ReliefMapPageState extends State{ child:FloatingActionButton.extended( onPressed: () { if (loginStatus){ - _showQuantityModal(context); + _getAddress(_lastMapPosition, asString:true) + .then((value) => _showQuantityModal(context,value)); }else{ Navigator.of(context).pushNamed('/login').then((value){ setState(() { @@ -153,7 +151,7 @@ class _ReliefMapPageState extends State{ ), ), _currentPosition != null ? Padding( - padding: const EdgeInsets.all(0), + padding: const EdgeInsets.fromLTRB(0, 0, 0, 40), child: Align( alignment: Alignment.center, child: Icon( @@ -220,14 +218,14 @@ class _ReliefMapPageState extends State{ }); } - _showQuantityModal(context){ + _showQuantityModal(context,_locationName){ final _formKey = GlobalKey(); int _quantity; showModalBottomSheet(context: context, isScrollControlled: true, builder: (context)=> Container( color: Colors.red[50], - height: 180, + height: 250, child:Stack( children: [ Form( @@ -261,6 +259,32 @@ class _ReliefMapPageState extends State{ ), ), ), + Padding( + padding: const EdgeInsets.all(10.0), + child:Align( + alignment: Alignment.topCenter, + child: TextFormField( + initialValue: _locationName, + decoration: const InputDecoration( + hintText: 'Current Location Name', + icon: Icon(Icons.add_location), + ), + inputFormatters: [ + ], + validator: (value) { + if (value.isEmpty) { + return 'Please enter current location Name'; + } + return null; + }, + onChanged: (value){ + setState(() { + _locationName = value; + }); + }, + ), + ), + ), Padding( padding: const EdgeInsets.symmetric(vertical: 25.0,horizontal: 140.0), child:Align( @@ -280,7 +304,7 @@ class _ReliefMapPageState extends State{ // the form is invalid. if (_formKey.currentState.validate()) { // Process data. - createReliefRecord(name,_quantity,"Weekly"); + createReliefRecord(name,_quantity,_locationName,"Weekly"); Navigator.pop(context); _addMarker(name,_quantity,"Weekly",null); _addHeatmap(_quantity,null); @@ -300,31 +324,56 @@ class _ReliefMapPageState extends State{ // ------------------ I/O functions ------------ // Reference https://alligator.io/flutter/geolocator-plugin/ _getCurrentLocation () { - final Geolocator geolocator = Geolocator()..forceAndroidLocationManager; - geolocator - .getCurrentPosition(desiredAccuracy: LocationAccuracy.best) - .then((Position position) { - setState(() { - _currentPosition = position; - }); - }).catchError((e) { - print(e); + Geolocator().checkGeolocationPermissionStatus().then((var onValue){ + if(onValue == GeolocationStatus.granted){ + final Geolocator geolocator = Geolocator()..forceAndroidLocationManager; + geolocator + .getCurrentPosition(desiredAccuracy: LocationAccuracy.best) + .then((Position position) { + setState(() { + _currentPosition = position; + }); + }).catchError((e) { + print(e); + }); + } }); + } // reference https://medium.com/@atul.sharma_94062/how-to-use-cloud-firestore-with-flutter-e6f9e8821b27 - void createReliefRecord(name,quantity,packageType) async { + void createReliefRecord(name,quantity,locationName,packageType) async { Timestamp time = Timestamp.now(); CollectionReference reliefCollection = databaseReference.collection("relief"); + List locationDetails = await _getAddress(_lastMapPosition); + print(locationName); await reliefCollection.document().setData({ 'name': name, 'quantity': quantity, 'location': GeoPoint(_lastMapPosition.latitude,_lastMapPosition.longitude), 'package_type':packageType, + 'location_name': locationName, + 'location_details':locationDetails, 'time':time, 'submitted_by':email }); + } + Future _getAddress(LatLng location,{bool asString}) async { + List placemarks = await Geolocator() + .placemarkFromCoordinates(location.latitude, location.longitude,localeIdentifier: 'en'); + if (placemarks != null && placemarks.isNotEmpty) { + final Placemark pos = placemarks[0]; + if(asString!=null && asString){ + return pos.thoroughfare+','+pos.subLocality+','+pos.locality+','+pos.subAdministrativeArea+','+pos.country; + } + return [pos.thoroughfare,pos.subLocality , pos.locality, pos.subAdministrativeArea,pos.country]; + } + if(asString!=null && asString){ + return ''; + } + return []; + } void getReliefData() { databaseReference @@ -355,20 +404,22 @@ class _ReliefMapPageState extends State{ // https://pub.dev/packages/flutter_google_places#-example-tab- - void _handleSearch(){ + void _handleSearch(searchWord){ // show input autocomplete with selected mode // then get the Prediction selected PlacesAutocomplete.show( + startText: searchWord, context: context, apiKey: kGoogleApiKey, onError: onSearchError, mode: Mode.overlay, region: "bd", language: "en", - // components: [Component(Component.country, "en")], ).then((p){ - print("place id $p.placeId"); displayPrediction(p); + setState(() { + searchTextController.text= p.description; + }); }); } void onSearchError(PlacesAutocompleteResponse response) { @@ -377,20 +428,19 @@ class _ReliefMapPageState extends State{ ); } Future displayPrediction(Prediction p) async { - if (p != null) { - // get detail (lat/lng) - PlacesDetailsResponse detail = await _places.getDetailsByPlaceId(p.placeId); - final lat = detail.result.geometry.location.lat; - final lng = detail.result.geometry.location.lng; - print(detail.result.name); - LatLng searchedLatLng = LatLng(lat, lng); - mapController.moveCamera(CameraUpdate.newLatLng(searchedLatLng)); - Scaffold.of(context).showSnackBar( - SnackBar(content: Text("${p.description} - $lat/$lng")), - ); + if (p != null) { + // get detail (lat/lng) + PlacesDetailsResponse detail = await _places.getDetailsByPlaceId(p.placeId); + final lat = detail.result.geometry.location.lat; + final lng = detail.result.geometry.location.lng; + LatLng searchedLatLng = LatLng(lat, lng); + mapController.moveCamera(CameraUpdate.newLatLng(searchedLatLng)); + // Scaffold.of(context).showSnackBar( + // SnackBar(content: Text("${p.description} - $lat/$lng")), + // ); + } } } -} From 50ea38bb0d8a0c0af615bf8dfe86acb339864dea Mon Sep 17 00:00:00 2001 From: "bm.abir" Date: Sat, 25 Apr 2020 05:28:19 +0600 Subject: [PATCH 4/4] marker shows location name --- lib/ui/reliefMapPage.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ui/reliefMapPage.dart b/lib/ui/reliefMapPage.dart index f50ebbb..ad54344 100644 --- a/lib/ui/reliefMapPage.dart +++ b/lib/ui/reliefMapPage.dart @@ -172,7 +172,7 @@ class _ReliefMapPageState extends State{ _lastMapPosition = position.target; } // ------------------- View Functions ------------------------ - void _addMarker(orgName,quantity,packageType,location) { + void _addMarker(orgName,quantity,locationName,packageType,location) { quantity=quantity.toString(); if(location == null){ location=_lastMapPosition; @@ -185,7 +185,7 @@ class _ReliefMapPageState extends State{ position: location, infoWindow: InfoWindow( title: 'Your/Organization Name: $orgName', - snippet: '$packageType package with Quantity: $quantity ', + snippet: '$packageType package with Quantity: $quantity in $locationName', ), icon: BitmapDescriptor.defaultMarkerWithHue(0), ) @@ -306,7 +306,7 @@ class _ReliefMapPageState extends State{ // Process data. createReliefRecord(name,_quantity,_locationName,"Weekly"); Navigator.pop(context); - _addMarker(name,_quantity,"Weekly",null); + _addMarker(name,_quantity,_locationName,"Weekly",null); _addHeatmap(_quantity,null); } }, @@ -384,7 +384,7 @@ class _ReliefMapPageState extends State{ // Ref https://fireship.io/lessons/flutter-realtime-geolocation-firebase/ GeoPoint pos = f.data['location']; LatLng latLng = new LatLng(pos.latitude, pos.longitude); - _addMarker(f.data['name'],f.data['quantity'],f.data['package_type'],latLng); + _addMarker(f.data['name'],f.data['quantity'],f.data['location_name'],f.data['package_type'],latLng); _addHeatmap(f.data['quantity'],latLng); });