Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Fabien MILLERAND <fab.millerand@automattic.com>
  • Loading branch information
Fabien MILLERAND committed Mar 9, 2024
1 parent c8815e7 commit 6dddcd5
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions lib/src/platform_maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ typedef CameraPositionCallback = void Function(CameraPosition position);

class PlatformMap extends StatefulWidget {
const PlatformMap({
Key? key,
super.key,
required this.initialCameraPosition,
this.onMapCreated,
this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
Expand All @@ -31,7 +31,7 @@ class PlatformMap extends StatefulWidget {
this.onCameraIdle,
this.onTap,
this.onLongPress,
}) : super(key: key);
});

/// Callback method for when the map is ready to be used.
///
Expand Down Expand Up @@ -172,7 +172,8 @@ class _PlatformMapState extends State<PlatformMap> {
Widget build(BuildContext context) {
if (Platform.isAndroid) {
return google_maps.GoogleMap(
initialCameraPosition: widget.initialCameraPosition.googleMapsCameraPosition,
initialCameraPosition:
widget.initialCameraPosition.googleMapsCameraPosition,
compassEnabled: widget.compassEnabled,
mapType: _getGoogleMapType(),
padding: widget.padding,
Expand All @@ -195,11 +196,13 @@ class _PlatformMapState extends State<PlatformMap> {
onTap: _onTap,
onLongPress: _onLongPress,
trafficEnabled: widget.trafficEnabled,
minMaxZoomPreference: widget.minMaxZoomPreference.googleMapsZoomPreference,
minMaxZoomPreference:
widget.minMaxZoomPreference.googleMapsZoomPreference,
);
} else if (Platform.isIOS) {
return apple_maps.AppleMap(
initialCameraPosition: widget.initialCameraPosition.appleMapsCameraPosition,
initialCameraPosition:
widget.initialCameraPosition.appleMapsCameraPosition,
compassEnabled: widget.compassEnabled,
mapType: _getAppleMapType(),
padding: widget.padding,
Expand All @@ -221,7 +224,8 @@ class _PlatformMapState extends State<PlatformMap> {
onTap: _onTap,
onLongPress: _onLongPress,
trafficEnabled: widget.trafficEnabled,
minMaxZoomPreference: widget.minMaxZoomPreference.appleMapsZoomPreference,
minMaxZoomPreference:
widget.minMaxZoomPreference.appleMapsZoomPreference,
);
} else {
return const Text("Platform not yet implemented");
Expand Down Expand Up @@ -250,17 +254,21 @@ class _PlatformMapState extends State<PlatformMap> {

void _onTap(dynamic position) {
if (Platform.isIOS) {
widget.onTap?.call(LatLng._fromAppleLatLng(position as apple_maps.LatLng));
widget.onTap
?.call(LatLng._fromAppleLatLng(position as apple_maps.LatLng));
} else if (Platform.isAndroid) {
widget.onTap?.call(LatLng._fromGoogleLatLng(position as google_maps.LatLng));
widget.onTap
?.call(LatLng._fromGoogleLatLng(position as google_maps.LatLng));
}
}

void _onLongPress(dynamic position) {
if (Platform.isIOS) {
widget.onLongPress?.call(LatLng._fromAppleLatLng(position as apple_maps.LatLng));
widget.onLongPress
?.call(LatLng._fromAppleLatLng(position as apple_maps.LatLng));
} else if (Platform.isAndroid) {
widget.onLongPress?.call(LatLng._fromGoogleLatLng(position as google_maps.LatLng));
widget.onLongPress
?.call(LatLng._fromGoogleLatLng(position as google_maps.LatLng));
}
}

Expand Down

0 comments on commit 6dddcd5

Please sign in to comment.