Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien MILLERAND committed Mar 9, 2024
1 parent c756a44 commit ce954e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/platform_maps_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ library platform_maps_flutter;

import 'dart:io';

import 'package:apple_maps_flutter/apple_maps_flutter.dart' as appleMaps;
import 'package:apple_maps_flutter/apple_maps_flutter.dart' as apple_maps;
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
Expand Down
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 ce954e1

Please sign in to comment.