Add Dialog with Pageview to select new house, and then drop a pin where the house is, then zoom map to that area.
This commit is contained in:
@@ -3,6 +3,8 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:wheres_my_sign/models/property.dart';
|
||||
import 'package:wheres_my_sign/widgets/custom_dialog_box.dart';
|
||||
|
||||
Future<void> main() async {
|
||||
await dotenv.load(fileName: ".env");
|
||||
@@ -88,6 +90,81 @@ class SignMapScreenState extends State<SignMapScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
// return something like this:
|
||||
// Property {
|
||||
// address: "1234 Smith St",
|
||||
// latitude: 37.7749,
|
||||
// longitude: -122.4194,
|
||||
// signLocations: [LatLng(37.77, -122.42), LatLng(37.775, -122.41)],
|
||||
// }
|
||||
void _addProperty() async {
|
||||
final Property? newProperty = await showDialog<Property>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return CustomDialogBox(
|
||||
title: "Show A Property",
|
||||
descriptions: "Let's show a new property!",
|
||||
text: "Yes",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (newProperty != null) {
|
||||
setState(() {
|
||||
// 🟢 Main property marker
|
||||
|
||||
markers.add(
|
||||
Marker(
|
||||
markerId: MarkerId(
|
||||
'property_${newProperty.latitude}_${newProperty.longitude}',
|
||||
),
|
||||
position: LatLng(newProperty.latitude, newProperty.longitude),
|
||||
icon: BitmapDescriptor.defaultMarkerWithHue(
|
||||
BitmapDescriptor.hueGreen,
|
||||
),
|
||||
infoWindow: InfoWindow(title: newProperty.address),
|
||||
),
|
||||
);
|
||||
|
||||
// 🔴 Sign location markers
|
||||
for (int i = 0; i < newProperty.signLocations.length; i++) {
|
||||
final LatLng signLocation = newProperty.signLocations[i];
|
||||
markers.add(
|
||||
Marker(
|
||||
markerId: MarkerId('sign_$i'),
|
||||
position: signLocation,
|
||||
icon: BitmapDescriptor.defaultMarkerWithHue(
|
||||
BitmapDescriptor.hueRed,
|
||||
),
|
||||
infoWindow: InfoWindow(title: 'Sign ${i + 1}'),
|
||||
),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Optionally: Move camera to property location
|
||||
mapController?.animateCamera(
|
||||
CameraUpdate.newLatLngZoom(
|
||||
LatLng(newProperty.latitude, newProperty.longitude),
|
||||
14.0,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// void _addProperty() async {
|
||||
// showDialog(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return CustomDialogBox(
|
||||
// title: "Show A Property",
|
||||
// descriptions: "Let's show a new property!",
|
||||
// text: "Yes",
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
void _clearMarkers() {
|
||||
setState(() {
|
||||
markers.clear();
|
||||
@@ -125,6 +202,13 @@ class SignMapScreenState extends State<SignMapScreen> {
|
||||
floatingActionButton: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
FloatingActionButton(
|
||||
onPressed: _addProperty,
|
||||
backgroundColor: Colors.green,
|
||||
tooltip: 'Add new property',
|
||||
child: Icon(Icons.add_home),
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
FloatingActionButton(
|
||||
onPressed: _addMarker,
|
||||
tooltip: 'Drop Pin',
|
||||
|
||||
Reference in New Issue
Block a user