Skip to content

Commit

Permalink
fix: center current location not working & location marker color on s…
Browse files Browse the repository at this point in the history
…atellite map
  • Loading branch information
LorenzSchueler committed Sep 10, 2024
1 parent f74d3f3 commit 6c9baef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions sport-log-client/lib/helpers/map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ class MapController {
geometry: latLng.toPoint(),
circleRadius: _markerRadius,
circleColor: color,
circleOpacity: 0.5,
circleOpacity: 0.8,
),
CircleAnnotationOptions(
geometry: latLng.toPoint(),
circleRadius: isGps ? _gpsMarkerRadius : _noGpsMarkerRadius,
circleColor: color,
circleOpacity: 0.3,
circleOpacity: 0.4,
),
]))
?.cast();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CurrentLocationButton extends StatelessWidget {

final MapController mapController;
final LocationUtils locationUtils;
final bool centerLocation;
final Pointer<bool> centerLocation;
final NullablePointer<List<CircleAnnotation>> currentLocationMarker;

Future<void> _toggleCurrentLocation() async {
Expand All @@ -38,7 +38,7 @@ class CurrentLocationButton extends StatelessWidget {
}

Future<void> _onLocationUpdate(GpsPosition location) async {
if (centerLocation) {
if (centerLocation.object) {
await mapController.animateCenter(location.latLng);
}
await mapController.updateCurrentLocationMarker(
Expand Down
11 changes: 7 additions & 4 deletions sport-log-client/lib/widgets/map_widgets/mapbox_map_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class _MapboxMapWrapperState extends State<MapboxMapWrapper> {
MapController? _mapController;
final LocationUtils _locationUtils = LocationUtils(inBackground: false);

bool _centerLocation = true;
final Pointer<bool> _centerLocation = Pointer(true);
Route? _selectedRoute;

final NullablePointer<List<CircleAnnotation>> _currentLocationMarker =
Expand Down Expand Up @@ -201,10 +201,13 @@ class _MapboxMapWrapperState extends State<MapboxMapWrapper> {
],
if (widget.showCenterLocationButton) ...[
ToggleCenterLocationButton(
centerLocation: _centerLocation,
centerLocation: _centerLocation.object,
onToggle: () {
setState(() => _centerLocation = !_centerLocation);
widget.onCenterLocationToggle?.call(_centerLocation);
setState(
() => _centerLocation.object = !_centerLocation.object,
);
widget.onCenterLocationToggle
?.call(_centerLocation.object);
},
),
Defaults.sizedBox.vertical.normal,
Expand Down

0 comments on commit 6c9baef

Please sign in to comment.