Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Complete Map Types list #43

Open
wants to merge 3 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
8 changes: 6 additions & 2 deletions example/lib/snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
});
Expand Down
2 changes: 1 addition & 1 deletion example/test_driver/test_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import 'package:flutter/widgets.dart';

Future<void> pumpWidget(Widget widget) {
runApp(widget);
return WidgetsBinding.instance!.endOfFrame;
return WidgetsBinding.instance.endOfFrame;
}
1 change: 1 addition & 0 deletions ios/Classes/MapView/AppleMapController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions ios/Classes/MapView/FlutterMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class FlutterMapView: MKMapView, UIGestureRecognizerDelegate {
MKMapType.standard,
MKMapType.satellite,
MKMapType.hybrid,
MKMapType.satelliteFlyover,
MKMapType.hybridFlyover,
MKMapType.mutedStandard,
]

let userTrackingModes: Array<MKUserTrackingMode> = [
Expand Down
12 changes: 12 additions & 0 deletions ios/Classes/models/SnapshotOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Any>) {
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> = [
MKMapType.standard,
MKMapType.satellite,
MKMapType.hybrid,
MKMapType.satelliteFlyover,
MKMapType.hybridFlyover,
MKMapType.mutedStandard,
]
}
6 changes: 5 additions & 1 deletion lib/src/snapshot_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() => <String, bool>{
dynamic _toMap() => <String, dynamic>{
'showBuildings': showBuildings,
'showPointsOfInterest': showPointsOfInterest,
'showAnnotations': showAnnotations,
'showOverlays': showOverlays,
'mapType': mapType.index,
};

@visibleForTesting
Expand All @@ -30,6 +33,7 @@ class SnapshotOptions {
showPointsOfInterest: json['showPointsOfInterest'],
showAnnotations: json['showAnnotations'],
showOverlays: json['showOverlays'],
mapType: MapType.values[json['mapType']],
);
}

Expand Down
9 changes: 9 additions & 0 deletions lib/src/ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down