|
5 | 5 | package io.flutter.plugins.googlemaps; |
6 | 6 |
|
7 | 7 | import android.content.Context; |
| 8 | + |
8 | 9 | import com.google.android.gms.maps.GoogleMapOptions; |
9 | 10 | import com.google.android.gms.maps.model.CameraPosition; |
10 | 11 | import com.google.android.gms.maps.model.LatLngBounds; |
| 12 | + |
11 | 13 | import io.flutter.plugin.common.PluginRegistry; |
| 14 | + |
12 | 15 | import java.util.concurrent.atomic.AtomicInteger; |
13 | 16 |
|
14 | 17 | class GoogleMapBuilder implements GoogleMapOptionsSink { |
15 | | - private final GoogleMapOptions options = new GoogleMapOptions(); |
16 | | - private boolean trackCameraPosition = false; |
17 | | - private boolean myLocationEnabled = false; |
18 | | - |
19 | | - GoogleMapController build( |
20 | | - int id, Context context, AtomicInteger state, PluginRegistry.Registrar registrar) { |
21 | | - final GoogleMapController controller = |
22 | | - new GoogleMapController(id, context, state, registrar, options); |
23 | | - controller.init(); |
24 | | - controller.setMyLocationEnabled(myLocationEnabled); |
25 | | - controller.setTrackCameraPosition(trackCameraPosition); |
26 | | - return controller; |
27 | | - } |
28 | | - |
29 | | - @Override |
30 | | - public void setCameraPosition(CameraPosition position) { |
31 | | - options.camera(position); |
32 | | - } |
33 | | - |
34 | | - @Override |
35 | | - public void setCompassEnabled(boolean compassEnabled) { |
36 | | - options.compassEnabled(compassEnabled); |
37 | | - } |
38 | | - |
39 | | - @Override |
40 | | - public void setCameraTargetBounds(LatLngBounds bounds) { |
41 | | - options.latLngBoundsForCameraTarget(bounds); |
42 | | - } |
43 | | - |
44 | | - @Override |
45 | | - public void setMapType(int mapType) { |
46 | | - options.mapType(mapType); |
47 | | - } |
48 | | - |
49 | | - @Override |
50 | | - public void setMinMaxZoomPreference(Float min, Float max) { |
51 | | - if (min != null) { |
52 | | - options.minZoomPreference(min); |
| 18 | + private final GoogleMapOptions options = new GoogleMapOptions(); |
| 19 | + private boolean trackCameraPosition = false; |
| 20 | + private boolean myLocationEnabled = false; |
| 21 | + |
| 22 | + GoogleMapController build( |
| 23 | + int id, Context context, AtomicInteger state, PluginRegistry.Registrar registrar) { |
| 24 | + final GoogleMapController controller = |
| 25 | + new GoogleMapController(id, context, state, registrar, options); |
| 26 | + controller.init(); |
| 27 | + controller.setMyLocationEnabled(myLocationEnabled); |
| 28 | + controller.setTrackCameraPosition(trackCameraPosition); |
| 29 | + return controller; |
53 | 30 | } |
54 | | - if (max != null) { |
55 | | - options.maxZoomPreference(max); |
| 31 | + |
| 32 | + @Override |
| 33 | + public void setCameraPosition(CameraPosition position) { |
| 34 | + options.camera(position); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public void setCompassEnabled(boolean compassEnabled) { |
| 39 | + options.compassEnabled(compassEnabled); |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public void setCameraTargetBounds(LatLngBounds bounds) { |
| 44 | + options.latLngBoundsForCameraTarget(bounds); |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public void setMapType(int mapType) { |
| 49 | + options.mapType(mapType); |
| 50 | + } |
| 51 | + |
| 52 | + @Override |
| 53 | + public void setMinMaxZoomPreference(Float min, Float max) { |
| 54 | + if (min != null) { |
| 55 | + options.minZoomPreference(min); |
| 56 | + } |
| 57 | + if (max != null) { |
| 58 | + options.maxZoomPreference(max); |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + @Override |
| 63 | + public void setTrackCameraPosition(boolean trackCameraPosition) { |
| 64 | + this.trackCameraPosition = trackCameraPosition; |
| 65 | + } |
| 66 | + |
| 67 | + @Override |
| 68 | + public void setRotateGesturesEnabled(boolean rotateGesturesEnabled) { |
| 69 | + options.rotateGesturesEnabled(rotateGesturesEnabled); |
| 70 | + } |
| 71 | + |
| 72 | + @Override |
| 73 | + public void setScrollGesturesEnabled(boolean scrollGesturesEnabled) { |
| 74 | + options.scrollGesturesEnabled(scrollGesturesEnabled); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public void setTiltGesturesEnabled(boolean tiltGesturesEnabled) { |
| 79 | + options.tiltGesturesEnabled(tiltGesturesEnabled); |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public void setZoomGesturesEnabled(boolean zoomGesturesEnabled) { |
| 84 | + options.zoomGesturesEnabled(zoomGesturesEnabled); |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + public void setMyLocationEnabled(boolean myLocationEnabled) { |
| 89 | + this.myLocationEnabled = myLocationEnabled; |
56 | 90 | } |
57 | | - } |
58 | | - |
59 | | - @Override |
60 | | - public void setTrackCameraPosition(boolean trackCameraPosition) { |
61 | | - this.trackCameraPosition = trackCameraPosition; |
62 | | - } |
63 | | - |
64 | | - @Override |
65 | | - public void setRotateGesturesEnabled(boolean rotateGesturesEnabled) { |
66 | | - options.rotateGesturesEnabled(rotateGesturesEnabled); |
67 | | - } |
68 | | - |
69 | | - @Override |
70 | | - public void setScrollGesturesEnabled(boolean scrollGesturesEnabled) { |
71 | | - options.scrollGesturesEnabled(scrollGesturesEnabled); |
72 | | - } |
73 | | - |
74 | | - @Override |
75 | | - public void setTiltGesturesEnabled(boolean tiltGesturesEnabled) { |
76 | | - options.tiltGesturesEnabled(tiltGesturesEnabled); |
77 | | - } |
78 | | - |
79 | | - @Override |
80 | | - public void setZoomGesturesEnabled(boolean zoomGesturesEnabled) { |
81 | | - options.zoomGesturesEnabled(zoomGesturesEnabled); |
82 | | - } |
83 | | - |
84 | | - @Override |
85 | | - public void setMyLocationEnabled(boolean myLocationEnabled) { |
86 | | - this.myLocationEnabled = myLocationEnabled; |
87 | | - } |
88 | 91 | } |
0 commit comments