Skip to content

Add liteModeEnabled (Google Maps), mapToolbarEnabled (Google Maps) and trackingMode (Apple Maps) #44

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.3

* Adds `trackingMode` to Apple Maps
* Adds `liteModeEnabled` to Google Maps
* Adds `mapToolbarEnabled` to Google Maps

## 1.0.2

* Updates apple_maps_flutter to apply memory leak fix
Expand Down
28 changes: 28 additions & 0 deletions lib/src/platform_maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class PlatformMap extends StatefulWidget {
this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{},
this.compassEnabled = true,
this.mapType = MapType.normal,
this.liteModeEnabled = false,
this.trackingMode = TrackingMode.none,
this.mapToolbarEnabled = true,
this.minMaxZoomPreference = MinMaxZoomPreference.unbounded,
this.rotateGesturesEnabled = true,
this.scrollGesturesEnabled = true,
Expand Down Expand Up @@ -47,6 +50,17 @@ class PlatformMap extends StatefulWidget {
/// Type of map tiles to be rendered.
final MapType mapType;

/// True if the map view should be in lite mode. Google Maps only.
///
/// See https://developers.google.com/maps/documentation/android-sdk/lite#overview_of_lite_mode for more details.
final bool liteModeEnabled;

/// The mode used to track the user location. Apple maps only.
final TrackingMode trackingMode;

/// True if the toolbar for google maps should show.
final bool mapToolbarEnabled;

/// Preferred bounds for the camera zoom level.
///
/// Actual bounds depend on map data and device.
Expand Down Expand Up @@ -191,13 +205,15 @@ class _PlatformMapState extends State<PlatformMap> {
zoomControlsEnabled: widget.zoomControlsEnabled,
zoomGesturesEnabled: widget.zoomGesturesEnabled,
scrollGesturesEnabled: widget.scrollGesturesEnabled,
liteModeEnabled: widget.liteModeEnabled,
onMapCreated: _onMapCreated,
onCameraMove: _onCameraMove,
onTap: _onTap,
onLongPress: _onLongPress,
trafficEnabled: widget.trafficEnabled,
minMaxZoomPreference:
widget.minMaxZoomPreference.googleMapsZoomPreference,
mapToolbarEnabled: widget.mapToolbarEnabled,
);
} else if (Platform.isIOS) {
return appleMaps.AppleMap(
Expand All @@ -214,6 +230,7 @@ class _PlatformMapState extends State<PlatformMap> {
onCameraIdle: widget.onCameraIdle,
myLocationButtonEnabled: widget.myLocationButtonEnabled,
myLocationEnabled: widget.myLocationEnabled,
trackingMode: _getAppleMapTrackingMode(),
onCameraMoveStarted: widget.onCameraMoveStarted,
pitchGesturesEnabled: widget.tiltGesturesEnabled,
rotateGesturesEnabled: widget.rotateGesturesEnabled,
Expand Down Expand Up @@ -292,4 +309,15 @@ class _PlatformMapState extends State<PlatformMap> {
}
return googleMaps.MapType.normal;
}

appleMaps.TrackingMode _getAppleMapTrackingMode() {
if (widget.trackingMode == TrackingMode.none) {
return appleMaps.TrackingMode.none;
} else if (widget.trackingMode == TrackingMode.follow) {
return appleMaps.TrackingMode.follow;
} else if (widget.trackingMode == TrackingMode.followWithHeading) {
return appleMaps.TrackingMode.followWithHeading;
}
return appleMaps.TrackingMode.none;
}
}
11 changes: 11 additions & 0 deletions lib/src/ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ enum MapType {
hybrid,
}

enum TrackingMode {
// the user's location is not followed
none,

// the map follows the user's location
follow,

// the map follows the user's location and heading
followWithHeading,
}

// Used with [PlatformMapOptions] to wrap min and max zoom. This allows
// distinguishing between specifying unbounded zooming (null `minZoom` and
// `maxZoom`) from not specifying anything (null `MinMaxZoomPreference`).
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: platform_maps_flutter
description: A Flutter package that combines google_maps and apple_maps to provide a crossplatform native map implementation.
version: 1.0.2
version: 1.0.3
homepage: https://github.com/LuisThein
repository: https://github.com/LuisThein/platform_maps_flutter
issue_tracker: https://github.com/LuisThein/platform_maps_flutter/issues
Expand Down