3030import com .google .android .gms .maps .GoogleMapOptions ;
3131import com .google .android .gms .maps .MapView ;
3232import com .google .android .gms .maps .OnMapReadyCallback ;
33- import com .google .android .gms .maps .model .CameraPosition ;
3433import com .google .android .gms .maps .model .Circle ;
3534import com .google .android .gms .maps .model .LatLng ;
3635import com .google .android .gms .maps .model .LatLngBounds ;
4443import com .google .maps .android .collections .MarkerManager ;
4544import io .flutter .embedding .engine .plugins .activity .ActivityPluginBinding ;
4645import io .flutter .plugin .common .BinaryMessenger ;
47- import io .flutter .plugin .common .MethodChannel ;
4846import io .flutter .plugin .platform .PlatformView ;
4947import io .flutter .plugins .googlemaps .Messages .FlutterError ;
5048import io .flutter .plugins .googlemaps .Messages .MapsApi ;
49+ import io .flutter .plugins .googlemaps .Messages .MapsCallbackApi ;
5150import io .flutter .plugins .googlemaps .Messages .MapsInspectorApi ;
5251import java .io .ByteArrayOutputStream ;
5352import java .util .ArrayList ;
54- import java .util .Collections ;
55- import java .util .HashMap ;
5653import java .util .List ;
5754import java .util .Map ;
5855import java .util .Objects ;
@@ -73,7 +70,7 @@ class GoogleMapController
7370
7471 private static final String TAG = "GoogleMapController" ;
7572 private final int id ;
76- private final MethodChannel methodChannel ;
73+ private final MapsCallbackApi flutterApi ;
7774 private final BinaryMessenger binaryMessenger ;
7875 private final GoogleMapOptions options ;
7976 @ Nullable private MapView mapView ;
@@ -121,19 +118,18 @@ class GoogleMapController
121118 this .mapView = new MapView (context , options );
122119 this .density = context .getResources ().getDisplayMetrics ().density ;
123120 this .binaryMessenger = binaryMessenger ;
124- methodChannel =
125- new MethodChannel (binaryMessenger , "plugins.flutter.dev/google_maps_android_" + id );
121+ flutterApi = new MapsCallbackApi (binaryMessenger , Integer .toString (id ));
126122 MapsApi .setUp (binaryMessenger , Integer .toString (id ), this );
127123 MapsInspectorApi .setUp (binaryMessenger , Integer .toString (id ), this );
128124 AssetManager assetManager = context .getAssets ();
129125 this .lifecycleProvider = lifecycleProvider ;
130- this .clusterManagersController = new ClusterManagersController (methodChannel , context );
126+ this .clusterManagersController = new ClusterManagersController (flutterApi , context );
131127 this .markersController =
132- new MarkersController (methodChannel , clusterManagersController , assetManager , density );
133- this .polygonsController = new PolygonsController (methodChannel , density );
134- this .polylinesController = new PolylinesController (methodChannel , assetManager , density );
135- this .circlesController = new CirclesController (methodChannel , density );
136- this .tileOverlaysController = new TileOverlaysController (methodChannel );
128+ new MarkersController (flutterApi , clusterManagersController , assetManager , density );
129+ this .polygonsController = new PolygonsController (flutterApi , density );
130+ this .polylinesController = new PolylinesController (flutterApi , assetManager , density );
131+ this .circlesController = new CirclesController (flutterApi , density );
132+ this .tileOverlaysController = new TileOverlaysController (flutterApi );
137133 }
138134
139135 // Constructor for testing purposes only
@@ -142,7 +138,7 @@ class GoogleMapController
142138 int id ,
143139 Context context ,
144140 BinaryMessenger binaryMessenger ,
145- MethodChannel methodChannel ,
141+ MapsCallbackApi flutterApi ,
146142 LifecycleProvider lifecycleProvider ,
147143 GoogleMapOptions options ,
148144 ClusterManagersController clusterManagersController ,
@@ -154,7 +150,7 @@ class GoogleMapController
154150 this .id = id ;
155151 this .context = context ;
156152 this .binaryMessenger = binaryMessenger ;
157- this .methodChannel = methodChannel ;
153+ this .flutterApi = flutterApi ;
158154 this .options = options ;
159155 this .mapView = new MapView (context , options );
160156 this .density = context .getResources ().getDisplayMetrics ().density ;
@@ -182,10 +178,6 @@ void init() {
182178 mapView .getMapAsync (this );
183179 }
184180
185- private CameraPosition getCameraPosition () {
186- return trackCameraPosition ? googleMap .getCameraPosition () : null ;
187- }
188-
189181 @ Override
190182 public void onMapReady (@ NonNull GoogleMap googleMap ) {
191183 this .googleMap = googleMap ;
@@ -298,24 +290,17 @@ public void onSurfaceTextureUpdated(@NonNull SurfaceTexture surface) {
298290
299291 @ Override
300292 public void onMapClick (@ NonNull LatLng latLng ) {
301- final Map <String , Object > arguments = new HashMap <>(2 );
302- arguments .put ("position" , Convert .latLngToJson (latLng ));
303- methodChannel .invokeMethod ("map#onTap" , arguments );
293+ flutterApi .onTap (Convert .latLngToPigeon (latLng ), new NoOpVoidResult ());
304294 }
305295
306296 @ Override
307297 public void onMapLongClick (@ NonNull LatLng latLng ) {
308- final Map <String , Object > arguments = new HashMap <>(2 );
309- arguments .put ("position" , Convert .latLngToJson (latLng ));
310- methodChannel .invokeMethod ("map#onLongPress" , arguments );
298+ flutterApi .onLongPress (Convert .latLngToPigeon (latLng ), new NoOpVoidResult ());
311299 }
312300
313301 @ Override
314302 public void onCameraMoveStarted (int reason ) {
315- final Map <String , Object > arguments = new HashMap <>(2 );
316- boolean isGesture = reason == GoogleMap .OnCameraMoveStartedListener .REASON_GESTURE ;
317- arguments .put ("isGesture" , isGesture );
318- methodChannel .invokeMethod ("camera#onMoveStarted" , arguments );
303+ flutterApi .onCameraMoveStarted (new NoOpVoidResult ());
319304 }
320305
321306 @ Override
@@ -328,15 +313,14 @@ public void onCameraMove() {
328313 if (!trackCameraPosition ) {
329314 return ;
330315 }
331- final Map <String , Object > arguments = new HashMap <>(2 );
332- arguments .put ("position" , Convert .cameraPositionToJson (googleMap .getCameraPosition ()));
333- methodChannel .invokeMethod ("camera#onMove" , arguments );
316+ flutterApi .onCameraMove (
317+ Convert .cameraPositionToPigeon (googleMap .getCameraPosition ()), new NoOpVoidResult ());
334318 }
335319
336320 @ Override
337321 public void onCameraIdle () {
338322 clusterManagersController .onCameraIdle ();
339- methodChannel . invokeMethod ( "camera#onIdle" , Collections . singletonMap ( "map" , id ));
323+ flutterApi . onCameraIdle ( new NoOpVoidResult ( ));
340324 }
341325
342326 @ Override
0 commit comments