Skip to content

Commit dfee27f

Browse files
committed
changed MapType implementation
1 parent fb48460 commit dfee27f

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

lib/src/platform_maps.dart

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,13 @@ class PlatformMap extends StatefulWidget {
149149
class _PlatformMapState extends State<PlatformMap> {
150150
@override
151151
Widget build(BuildContext context) {
152+
print(widget.mapType);
152153
if (Platform.isAndroid) {
153154
return googleMaps.GoogleMap(
154155
initialCameraPosition:
155156
widget.initialCameraPosition.googleMapsCameraPosition,
156157
compassEnabled: widget.compassEnabled,
157-
mapType: widget.mapType ?? MapType.normal,
158+
mapType: _getGoogleMapType(),
158159
markers: Marker.toGoogleMapsMarkerSet(widget.markers),
159160
gestureRecognizers: widget.gestureRecognizers,
160161
onCameraIdle: widget.onCameraIdle,
@@ -179,7 +180,7 @@ class _PlatformMapState extends State<PlatformMap> {
179180
initialCameraPosition:
180181
widget.initialCameraPosition.appleMapsCameraPosition,
181182
compassEnabled: widget.compassEnabled,
182-
mapType: widget.mapType ?? MapType.normal,
183+
mapType: _getAppleMapType(),
183184
annotations: Marker.toAppleMapsAnnotationSet(widget.markers),
184185
gestureRecognizers: widget.gestureRecognizers,
185186
onCameraIdle: widget.onCameraIdle,
@@ -211,4 +212,26 @@ class _PlatformMapState extends State<PlatformMap> {
211212
_onAppleMapCreated(appleMaps.AppleMapController controller) {
212213
widget.onMapCreated(PlatformMapController(controller));
213214
}
215+
216+
appleMaps.MapType _getAppleMapType() {
217+
if (widget.mapType == MapType.normal) {
218+
return appleMaps.MapType.standard;
219+
} else if (widget.mapType == MapType.satellite) {
220+
return appleMaps.MapType.satellite;
221+
} else if (widget.mapType == MapType.hybrid) {
222+
return appleMaps.MapType.hybrid;
223+
}
224+
return appleMaps.MapType.standard;
225+
}
226+
227+
googleMaps.MapType _getGoogleMapType() {
228+
if (widget.mapType == MapType.normal) {
229+
return googleMaps.MapType.normal;
230+
} else if (widget.mapType == MapType.satellite) {
231+
return googleMaps.MapType.satellite;
232+
} else if (widget.mapType == MapType.hybrid) {
233+
return googleMaps.MapType.hybrid;
234+
}
235+
return googleMaps.MapType.normal;
236+
}
214237
}

lib/src/ui.dart

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,15 @@
55
part of flutter_platform_maps;
66

77
/// Type of map tiles to display.
8-
class MapType {
9-
static get normal {
10-
if (Platform.isIOS) {
11-
return appleMaps.MapType.standard;
12-
} else if (Platform.isAndroid) {
13-
return googleMaps.MapType.normal;
14-
}
15-
}
8+
enum MapType {
9+
/// Normal tiles (traffic and labels, subtle terrain information).
10+
normal,
1611

17-
static get satallite {
18-
if (Platform.isIOS) {
19-
return appleMaps.MapType.satellite;
20-
} else if (Platform.isAndroid) {
21-
return googleMaps.MapType.satellite;
22-
}
23-
}
12+
/// Satellite imaging tiles (aerial photos)
13+
satellite,
2414

25-
static get hybrid {
26-
if (Platform.isIOS) {
27-
return appleMaps.MapType.hybrid;
28-
} else if (Platform.isAndroid) {
29-
return googleMaps.MapType.hybrid;
30-
}
31-
}
15+
/// Hybrid tiles (satellite images with some labels/overlays)
16+
hybrid,
3217
}
3318

3419
// Used with [GoogleMapOptions] to wrap min and max zoom. This allows

0 commit comments

Comments
 (0)