diff --git a/example/lib/snapshot.dart b/example/lib/snapshot.dart index b16f808..670cd31 100644 --- a/example/lib/snapshot.dart +++ b/example/lib/snapshot.dart @@ -11,7 +11,7 @@ import 'package:flutter/material.dart'; import 'package:apple_maps_flutter/apple_maps_flutter.dart'; const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); + CameraPosition(target: LatLng(-33.852, 151.211), zoom: 2.0); class SnapshotPage extends ExamplePage { SnapshotPage() @@ -44,12 +44,16 @@ class _SnapshotBodyState extends State<_SnapshotBody> { child: AppleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, + mapType: MapType.hybridFlyover, ), ), TextButton( child: Text('Take a snapshot'), onPressed: () async { - final imageBytes = await _mapController?.takeSnapshot(); + final imageBytes = + await _mapController?.takeSnapshot(SnapshotOptions( + mapType: MapType.hybridFlyover, + )); setState(() { _imageBytes = imageBytes; }); diff --git a/example/test_driver/test_widgets.dart b/example/test_driver/test_widgets.dart index d2c27fd..5656c9f 100644 --- a/example/test_driver/test_widgets.dart +++ b/example/test_driver/test_widgets.dart @@ -8,5 +8,5 @@ import 'package:flutter/widgets.dart'; Future pumpWidget(Widget widget) { runApp(widget); - return WidgetsBinding.instance!.endOfFrame; + return WidgetsBinding.instance.endOfFrame; } diff --git a/ios/Classes/MapView/AppleMapController.swift b/ios/Classes/MapView/AppleMapController.swift index 300f647..47b497d 100644 --- a/ios/Classes/MapView/AppleMapController.swift +++ b/ios/Classes/MapView/AppleMapController.swift @@ -315,6 +315,7 @@ extension AppleMapController { snapShotOptions.scale = UIScreen.main.scale snapShotOptions.showsBuildings = options.showBuildings snapShotOptions.showsPointsOfInterest = options.showPointsOfInterest + snapShotOptions.mapType = options.mapType // Set MKMapSnapShotOptions to MKMapSnapShotter. snapShot = MKMapSnapshotter(options: snapShotOptions) diff --git a/ios/Classes/MapView/FlutterMapView.swift b/ios/Classes/MapView/FlutterMapView.swift index 628d533..63028a1 100644 --- a/ios/Classes/MapView/FlutterMapView.swift +++ b/ios/Classes/MapView/FlutterMapView.swift @@ -27,6 +27,9 @@ class FlutterMapView: MKMapView, UIGestureRecognizerDelegate { MKMapType.standard, MKMapType.satellite, MKMapType.hybrid, + MKMapType.satelliteFlyover, + MKMapType.hybridFlyover, + MKMapType.mutedStandard, ] let userTrackingModes: Array = [ diff --git a/ios/Classes/models/SnapshotOptions.swift b/ios/Classes/models/SnapshotOptions.swift index faaf071..8356a63 100644 --- a/ios/Classes/models/SnapshotOptions.swift +++ b/ios/Classes/models/SnapshotOptions.swift @@ -6,17 +6,29 @@ // import Foundation +import MapKit class SnapshotOptions { let showBuildings: Bool let showPointsOfInterest: Bool let showAnnotations: Bool let showOverlays: Bool + let mapType : MKMapType init(options: Dictionary) { self.showBuildings = options["showBuildings"] as? Bool ?? true self.showPointsOfInterest = options["showPointsOfInterest"] as? Bool ?? true self.showAnnotations = options["showAnnotations"] as? Bool ?? true self.showOverlays = options["showOverlays"] as? Bool ?? true + self.mapType = mapTypes[options["mapType"] as? Int ?? 0] } + + let mapTypes: Array = [ + MKMapType.standard, + MKMapType.satellite, + MKMapType.hybrid, + MKMapType.satelliteFlyover, + MKMapType.hybridFlyover, + MKMapType.mutedStandard, + ] } diff --git a/lib/src/snapshot_options.dart b/lib/src/snapshot_options.dart index 222c46d..441ad7e 100644 --- a/lib/src/snapshot_options.dart +++ b/lib/src/snapshot_options.dart @@ -6,18 +6,21 @@ class SnapshotOptions { this.showPointsOfInterest = true, this.showAnnotations = true, this.showOverlays = true, + this.mapType = MapType.standard, }); final bool showBuildings; final bool showPointsOfInterest; final bool showAnnotations; final bool showOverlays; + final MapType mapType; - dynamic _toMap() => { + dynamic _toMap() => { 'showBuildings': showBuildings, 'showPointsOfInterest': showPointsOfInterest, 'showAnnotations': showAnnotations, 'showOverlays': showOverlays, + 'mapType': mapType.index, }; @visibleForTesting @@ -30,6 +33,7 @@ class SnapshotOptions { showPointsOfInterest: json['showPointsOfInterest'], showAnnotations: json['showAnnotations'], showOverlays: json['showOverlays'], + mapType: MapType.values[json['mapType']], ); } diff --git a/lib/src/ui.dart b/lib/src/ui.dart index d650a2a..57eaaa3 100644 --- a/lib/src/ui.dart +++ b/lib/src/ui.dart @@ -14,6 +14,15 @@ enum MapType { /// Hybrid tiles (satellite images with some labels/overlays) hybrid, + + // A satellite image of the area with flyover data where available. + satelliteFlyover, + + // A hybrid satellite image with flyover data where available. + hybridFlyover, + + // A street map where MapKit emphasizes your data over the underlying map details. + mutedStandard, } enum TrackingMode {