This repository was archived by the owner on Jun 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathmap_options.dart
More file actions
70 lines (66 loc) · 2.19 KB
/
map_options.dart
File metadata and controls
70 lines (66 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import 'package:cirrus_map_view/camera_position.dart';
import 'package:cirrus_map_view/location.dart';
import 'package:cirrus_map_view/map_view_type.dart';
class MapOptions {
/// Allows the app to receive location updates.
final bool showUserLocation;
/// show/hide the button to center the map on the user location.
///
/// Requires showUserLocation to be true.
final bool showMyLocationButton;
/// show/hide the compass button on the map.
///
/// Normally is not visible all the time. Becomes visible when the orientation
/// of the map is changes through gesture.
final bool showCompassButton;
/// show/hide the toolbar while on the map activity/view.
///
/// Actions passed to the MapView.show(MapOptions,<ToolbarAction>[]) function will not work
/// because they will not be visible.
final bool hideToolbar;
final CameraPosition initialCameraPosition;
final String title;
static const CameraPosition _defaultCamera =
const CameraPosition(const Location(45.5329661, -122.7059508), 12.0);
MapViewType mapViewType;
MapOptions(
{this.showUserLocation: false,
this.showMyLocationButton: false,
this.showCompassButton: false,
this.hideToolbar = false,
this.initialCameraPosition: _defaultCamera,
this.title: "",
this.mapViewType: MapViewType.normal});
Map<String, dynamic> toMap() {
return {
"showUserLocation": showUserLocation,
"showMyLocationButton": showMyLocationButton,
"showCompassButton": showCompassButton,
"hideToolbar": hideToolbar,
"cameraPosition": initialCameraPosition.toMap(),
"title": title,
"mapViewType": getMapTypeName(mapViewType)
};
}
String getMapTypeName(MapViewType mapType) {
String mapTypeName = "normal";
switch (mapType) {
case MapViewType.none:
mapTypeName = "none";
break;
case MapViewType.satellite:
mapTypeName = "satellite";
break;
case MapViewType.terrain:
mapTypeName = "terrain";
break;
case MapViewType.hybrid:
mapTypeName = "hybrid";
break;
case MapViewType.normal:
mapTypeName = "normal";
break;
}
return mapTypeName;
}
}