use structs to draw custom map pointers
This commit is contained in:
@@ -46,7 +46,8 @@ class _BasePageState extends State<BasePage> {
|
||||
child: const Text('The fanciest navigation!'),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Home'),
|
||||
title: const Text('Start'),
|
||||
leading: const Icon(Icons.map),
|
||||
selected: _selectedIndex == 0,
|
||||
onTap: () {
|
||||
// Update the state of the app
|
||||
@@ -57,7 +58,8 @@ class _BasePageState extends State<BasePage> {
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Business'),
|
||||
title: const Text('How to use'),
|
||||
leading: Icon(Icons.help),
|
||||
selected: _selectedIndex == 1,
|
||||
onTap: () {
|
||||
// Update the state of the app
|
||||
@@ -68,8 +70,6 @@ class _BasePageState extends State<BasePage> {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
// add a whitespace so that the settings are at the bottom
|
||||
|
||||
const Divider(),
|
||||
ListTile(
|
||||
title: const Text('Settings'),
|
||||
|
@@ -66,7 +66,7 @@ class _LandmarkCardState extends State<LandmarkCard> {
|
||||
// alignment: Alignment.topRight,
|
||||
// child: Icon(Icons.push_pin, color: theme.primaryColor),
|
||||
// ),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import 'package:fast_network_navigation/structs/landmark.dart';
|
||||
import 'package:fast_network_navigation/utils/get_landmarks.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
|
||||
@@ -10,33 +11,36 @@ class MapWidget extends StatefulWidget {
|
||||
class _MapWidgetState extends State<MapWidget> {
|
||||
late GoogleMapController mapController;
|
||||
// coordinates of Paris
|
||||
final LatLng _center = const LatLng(48.8566, 2.3522);
|
||||
CameraPosition _cameraPosition = CameraPosition(
|
||||
target: LatLng(48.8566, 2.3522),
|
||||
zoom: 11.0,
|
||||
);
|
||||
Set<Marker> markers = <Marker>{};
|
||||
|
||||
|
||||
void _onMapCreated(GoogleMapController controller) {
|
||||
mapController = controller;
|
||||
addLandmarks();
|
||||
drawLandmarks();
|
||||
}
|
||||
|
||||
|
||||
void _onCameraIdle() {
|
||||
// print(mapController.getLatLng());
|
||||
// print(mapController.getLatLng(ScreenCoordinate(x: 0, y: 0)));
|
||||
}
|
||||
|
||||
void addLandmarks() {
|
||||
// // adds a marker for each landmark
|
||||
// List<Landmark> landmarks = [
|
||||
// Landmark(name: "Eiffel Tower", location: [48.8584, 2.2945], type: LandmarkType(name: "Type 1")),
|
||||
// Landmark(name: "Louvre Museum", location: [48.8606, 2.3376], type: LandmarkType(name: "Type 1")),
|
||||
// Landmark(name: "Notre-Dame Cathedral", location: [48.8529, 2.3499], type: LandmarkType(name: "Type 1")),
|
||||
// Landmark(name: "Arc de Triomphe", location: [48.8738, 2.2950], type: LandmarkType(name: "Type 1")),
|
||||
// Landmark(name: "Palace of Versailles", location: [48.8014, 2.1301], type: LandmarkType(name: "Type 1")),
|
||||
// ];
|
||||
|
||||
// for (Landmark landmark in landmarks) {
|
||||
// mapController.
|
||||
// mapController.addMarker(MarkerOptions(
|
||||
// position: LatLng(landmark.location[0], landmark.location[1]),
|
||||
// infoWindowText: InfoWindowText(landmark.name, landmark.type.name),
|
||||
// ));
|
||||
// }
|
||||
void drawLandmarks() async {
|
||||
// (re)draws landmarks on the map
|
||||
List<Landmark> landmarks = await fetchLandmarks();
|
||||
setState(() {
|
||||
for (Landmark landmark in landmarks) {
|
||||
markers.add(Marker(
|
||||
markerId: MarkerId(landmark.name),
|
||||
position: LatLng(landmark.location[0], landmark.location[1]),
|
||||
infoWindow: InfoWindow(title: landmark.name, snippet: landmark.type.name),
|
||||
));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -44,61 +48,11 @@ class _MapWidgetState extends State<MapWidget> {
|
||||
Widget build(BuildContext context) {
|
||||
return GoogleMap(
|
||||
onMapCreated: _onMapCreated,
|
||||
initialCameraPosition: CameraPosition(
|
||||
target: _center,
|
||||
zoom: 11.0,
|
||||
),
|
||||
initialCameraPosition: _cameraPosition,
|
||||
onCameraIdle: _onCameraIdle,
|
||||
// onLongPress: ,
|
||||
// markers: #,
|
||||
markers: markers,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GeoCode geoCode = GeoCode();
|
||||
// String _currentCityName = "...";
|
||||
// final Debounce _debounce = Debounce(Duration(seconds: 3));
|
||||
|
||||
// final LatLng _center = const LatLng(45.521563, -122.677433);
|
||||
// late GoogleMapController mapController;
|
||||
|
||||
// void _onMapCreated(GoogleMapController controller) {
|
||||
// mapController = controller;
|
||||
// }
|
||||
|
||||
// // void _setCurrentCityName() async {
|
||||
// if (mapController.camera.zoom < 9) {
|
||||
// return; // Don't bother if the view is too wide
|
||||
// }
|
||||
// var currentCoordinates = mapController.camera.center;
|
||||
// String? city;
|
||||
|
||||
// try{
|
||||
// List<Placemark> placemarks = await placemarkFromCoordinates(currentCoordinates.latitude, currentCoordinates.longitude);
|
||||
// city = placemarks[0].locality.toString();
|
||||
// } catch (e) {
|
||||
// debugPrint("Error: $e");
|
||||
// try {
|
||||
// Address address = await geoCode.reverseGeocoding(latitude: currentCoordinates.latitude, longitude: currentCoordinates.longitude);
|
||||
|
||||
// if (address.city == null || address.city.toString().contains("Throttled!")){
|
||||
// throw Exception("Probably rate limited");
|
||||
// }
|
||||
// city = address.city.toString();
|
||||
// } catch (e) {
|
||||
// debugPrint("Error: $e");
|
||||
|
||||
// }
|
||||
// }
|
||||
// if (city != null) {
|
||||
// setState(() {
|
||||
// _currentCityName = city!;
|
||||
// });
|
||||
// } else {
|
||||
// _debounce(() async {_setCurrentCityName();});
|
||||
// }
|
||||
// }
|
||||
|
||||
|
@@ -24,11 +24,14 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||
child: Text('Curious traveler', style: TextStyle(fontSize: 24))
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
),
|
||||
Padding(padding: EdgeInsets.all(10)),
|
||||
Divider(indent: 25, endIndent: 25),
|
||||
Padding(padding: EdgeInsets.all(10)),
|
||||
|
||||
Text('Please rate your preferences for the following activities:'),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 10),
|
||||
child: Text('Please rate your personal preferences so that we can taylor your experience.', style: TextStyle(fontSize: 20), )
|
||||
),
|
||||
|
||||
// Now the sliders
|
||||
ImportanceSliders()
|
||||
|
@@ -10,11 +10,11 @@ Future<List<Landmark>> fetchLandmarks() async {
|
||||
// If the server did return a 200 OK response,
|
||||
// then parse the JSON.
|
||||
List<Landmark> landmarks = [
|
||||
Landmark(name: "Landmark 1", location: [0, 0], type: LandmarkType(name: "Type 1")),
|
||||
Landmark(name: "Landmark 2", location: [0, 0], type: LandmarkType(name: "Type 2")),
|
||||
Landmark(name: "Landmark 3", location: [0, 0], type: LandmarkType(name: "Type 3")),
|
||||
Landmark(name: "Landmark 4", location: [0, 0], type: LandmarkType(name: "Type 4")),
|
||||
Landmark(name: "Landmark 5", location: [0, 0], type: LandmarkType(name: "Type 5")),
|
||||
Landmark(name: "Landmark 1", location: [48.85, 2.35], type: LandmarkType(name: "Type 1")),
|
||||
Landmark(name: "Landmark 2", location: [48.86, 2.36], type: LandmarkType(name: "Type 2")),
|
||||
Landmark(name: "Landmark 3", location: [48.75, 2.3], type: LandmarkType(name: "Type 3")),
|
||||
Landmark(name: "Landmark 4", location: [48.9, 2.4], type: LandmarkType(name: "Type 4")),
|
||||
Landmark(name: "Landmark 5", location: [48.91, 2.45], type: LandmarkType(name: "Type 5")),
|
||||
];
|
||||
return landmarks;
|
||||
// } else {
|
||||
|
Reference in New Issue
Block a user