Skip to content

Commit

Permalink
Merge pull request #21 from xcarol/feature/add-administrativeboundari…
Browse files Browse the repository at this point in the history
…es-polygons

Feature/add administrativeboundaries polygons
  • Loading branch information
xcarol authored Feb 23, 2024
2 parents 19f87fe + d56cc7e commit fd8ff18
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 130 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ _secrets.properties_

## Application signing and publishing

As this is a one time process, I cannot step back to do the process again, so here it is useful information in case it is needed do this process again. God bless we don't.
As this is a one time process, I cannot step back to do the process again, so here it is useful information in case it is needed do this process again. God willing 🤞😅.

Links to follow:

Expand Down
File renamed without changes.
57 changes: 44 additions & 13 deletions lib/models/stacked_maps_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,49 @@ import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

class StackedMapsModel extends ChangeNotifier {
static LatLng barcelonaLocation =
const LatLng(-33.85999989127037, 151.1999999731779);
static LatLng sydneyLocation =
const LatLng(41.447178768107136, 2.1920866146683693);
static String barcelonaName = "Barcelona";
static String sydneyName = "Sydney";
static LatLng sydneyLocation = const LatLng(-33.8698439, 151.2082848);
static LatLng barcelonaLocation = const LatLng(41.3828939, 2.1774322);
static String barcelonaName = 'Barcelona';
static String sydneyName = 'Sydney';
static double initialOpacity = 0.3;
static double halfOpacity = 0.5;
static double opaque = 1.0;
static double defaultZoom = 11.0;
static Color colorRed = Colors.red;
static Color colorBlue = Colors.blue;
static PolylineId frontPlacePolylineId =
const PolylineId('frontPlacePolylineId');
static PolylineId backPlacePolylineId =
const PolylineId('backPlacePolylineId');

bool updateFrontMapLocation = false;
bool updateBackMapLocation = false;
bool _updateFrontMap = false;
bool _updateBackMap = false;

double _opacity = halfOpacity;
LatLng _frontPlaceLocation = sydneyLocation;
LatLng _backPlaceLocation = barcelonaLocation;
String _frontPlaceName = sydneyName;
String _backPlaceName = barcelonaName;
double _opacity = initialOpacity;
LatLng _frontPlaceLocation = barcelonaLocation;
LatLng _backPlaceLocation = sydneyLocation;
String _frontPlaceName = barcelonaName;
String _backPlaceName = sydneyName;
Color _frontPlaceBoundaryColor = colorRed;
Color _backPlaceBoundaryColor = colorBlue;

bool get updateFrontMap => _updateFrontMap;
bool get updateBackMap => _updateBackMap;
double get opacity => _opacity;
LatLng get frontPlaceLocation => _frontPlaceLocation;
LatLng get backPlaceLocation => _backPlaceLocation;
String get frontPlaceName => _frontPlaceName;
String get backPlaceName => _backPlaceName;
Color get frontPlaceBoundaryColor => _frontPlaceBoundaryColor;
Color get backPlaceBoundaryColor => _backPlaceBoundaryColor;

resetUpdateFrontMap() {
_updateFrontMap = false;
}

resetUpdateBackMap() {
_updateBackMap = false;
}

set opacity(double opacity) {
_opacity = opacity;
Expand All @@ -34,11 +53,13 @@ class StackedMapsModel extends ChangeNotifier {

set frontPlaceLocation(LatLng location) {
_frontPlaceLocation = location;
_updateFrontMap = true;
notifyListeners();
}

set backPlaceLocation(LatLng location) {
_backPlaceLocation = location;
_updateBackMap = true;
notifyListeners();
}

Expand All @@ -51,4 +72,14 @@ class StackedMapsModel extends ChangeNotifier {
_backPlaceName = name;
notifyListeners();
}

set frontPlaceBoundaryColor(Color color) {
_frontPlaceBoundaryColor = color;
notifyListeners();
}

set backPlaceBoundaryColor(Color color) {
_backPlaceBoundaryColor = color;
notifyListeners();
}
}
30 changes: 14 additions & 16 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:overmap/helpers/place.dart';
import 'package:overmap/models/place.dart';
import 'package:overmap/models/stacked_maps_model.dart';
import 'package:overmap/screens/search_place.dart';
import 'package:overmap/screens/stacked_maps.dart';
Expand All @@ -14,7 +14,9 @@ class Home extends StatefulWidget {
}

class _HomeState extends State<Home> {
late double _opacity = StackedMapsModel.halfOpacity;
final Color _rightBoundaryColor = StackedMapsModel.colorBlue;
final Color _leftBoundaryColor = StackedMapsModel.colorRed;
late double _opacity = StackedMapsModel.initialOpacity;
late String _rightName = StackedMapsModel.sydneyName;
late String _leftName = StackedMapsModel.barcelonaName;

Expand Down Expand Up @@ -49,28 +51,26 @@ class _HomeState extends State<Home> {
max: 1.0,
onChanged: sliderMoved);

void setBackPlace(Place place) {
void setBackPlace(Place place, Color boundaryColor) {
double latitude = place.lat;
double longitude = place.lng;
String name = place.name;

Provider.of<StackedMapsModel>(context, listen: false).backPlaceLocation =
LatLng(latitude, longitude);
Provider.of<StackedMapsModel>(context, listen: false).backPlaceName = name;
Provider.of<StackedMapsModel>(context, listen: false)
.updateBackMapLocation = true;
Provider.of<StackedMapsModel>(context, listen: false).backPlaceBoundaryColor = boundaryColor;
}

void setFrontPlace(Place place) {
void setFrontPlace(Place place, Color boundaryColor) {
double latitude = place.lat;
double longitude = place.lng;
String name = place.name;

Provider.of<StackedMapsModel>(context, listen: false).frontPlaceLocation =
LatLng(latitude, longitude);
Provider.of<StackedMapsModel>(context, listen: false).frontPlaceName = name;
Provider.of<StackedMapsModel>(context, listen: false)
.updateFrontMapLocation = true;
Provider.of<StackedMapsModel>(context, listen: false).frontPlaceBoundaryColor = boundaryColor;
}

searchPlace(Function selectedPlace) {
Expand All @@ -85,12 +85,11 @@ class _HomeState extends State<Home> {
searchPlace((Place place) {
setState(() {
if (isLeftPlaceInFront) {
setFrontPlace(place);
_leftName = place.name;
setFrontPlace(place, _leftBoundaryColor);
} else {
setBackPlace(place);
_leftName = place.name;
setBackPlace(place, _leftBoundaryColor);
}
_leftName = place.name;
});
Navigator.pop(context);
});
Expand All @@ -100,12 +99,11 @@ class _HomeState extends State<Home> {
searchPlace((Place place) {
setState(() {
if (isRightPlaceInFront) {
setFrontPlace(place);
_rightName = place.name;
setFrontPlace(place, _rightBoundaryColor);
} else {
setBackPlace(place);
_rightName = place.name;
setBackPlace(place, _rightBoundaryColor);
}
_rightName = place.name;
});
Navigator.pop(context);
});
Expand Down
14 changes: 7 additions & 7 deletions lib/screens/search_place.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:overmap/helpers/place.dart';
import 'package:overmap/services/google_places_service.dart';
import 'package:overmap/models/place.dart';
import 'package:overmap/services/places_service.dart';

class SearchPlace extends StatefulWidget {
final Function selectedPlace;
Expand All @@ -12,8 +12,8 @@ class SearchPlace extends StatefulWidget {
}

class _SearchPlaceState extends State<SearchPlace> {
final GooglePlacesService _service = GooglePlacesService(
mapsApiKey: const String.fromEnvironment("MAPS_API_KEY"));
final PlacesService _service = PlacesService(
googleMapsApiKey: const String.fromEnvironment("MAPS_API_KEY"));
late List placesListItems = List.empty();

@override
Expand All @@ -34,11 +34,11 @@ class _SearchPlaceState extends State<SearchPlace> {

selectPlace(place) {
_service.getPlaceDetails(place['place_id']).then((response) {
String status = response[GooglePlacesService.response.status];
String status = response[PlacesService.response.status];

if (status == GooglePlacesService.response.ok) {
if (status == PlacesService.response.ok) {
Map<String, dynamic> placeData =
response[GooglePlacesService.response.result];
response[PlacesService.response.result];

Place placeDetails = Place(details: placeData);

Expand Down
Loading

0 comments on commit fd8ff18

Please sign in to comment.