Skip to content

Commit

Permalink
fix: Use openstreetmap on FlutterMap if set via settings; closes #127
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Oct 5, 2023
1 parent fb2500b commit 146f111
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions lib/widgets/LocusFlutterMap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart';
import 'package:locus/constants/values.dart';
import 'package:locus/services/current_location_service.dart';
import 'package:locus/services/settings_service/index.dart';
import 'package:locus/utils/location/get-fallback-location.dart';
import 'package:locus/utils/theme.dart';
import 'package:locus/widgets/LocationsMap.dart';
Expand Down Expand Up @@ -42,9 +43,9 @@ class LocusFlutterMap extends StatelessWidget {
return currentLocation.currentPosition == null
? getFallbackLocation(context)
: LatLng(
currentLocation.currentPosition!.latitude,
currentLocation.currentPosition!.longitude,
);
currentLocation.currentPosition!.latitude,
currentLocation.currentPosition!.longitude,
);
}

double getInitialZoom(final BuildContext context) {
Expand Down Expand Up @@ -109,25 +110,29 @@ class LocusFlutterMap extends StatelessWidget {
zoom: getInitialZoom(context),
),
compassEnabled: true,
onTap: (location) => onTap?.call(LatLng(
location.latitude,
location.longitude,
)),
onLongPress: (location) => onLongPress?.call(LatLng(
location.latitude,
location.longitude,
)),
onTap: (location) =>
onTap?.call(LatLng(
location.latitude,
location.longitude,
)),
onLongPress: (location) =>
onLongPress?.call(LatLng(
location.latitude,
location.longitude,
)),
onMapCreated: onAppleMapCreated,
circles: appleMapCircles,
);
}

@override
Widget build(BuildContext context) {
if (flutterMapController != null) {
return buildFlutterMaps(context);
} else {
final settings = context.watch<SettingsService>();

if (settings.getMapProvider() == MapProvider.apple) {
return buildAppleMaps(context);
}

return buildFlutterMaps(context);
}
}

0 comments on commit 146f111

Please sign in to comment.