Update: hide the map view when you set the camera option for Map.getMap() method
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta2-20170718-1900" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta2-20170718-1936" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
src/android/plugin/google/maps/PluginMap.java
src/android/plugin/google/maps/PluginMap.java
@@ -314,7 +314,6 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
// ------------------------------
if (args.length() == 3) {
mapDivId = args.getString(2);
- RectF rectF;
mapCtrl.mPluginLayout.addPluginMap(PluginMap.this);
PluginMap.this.resizeMap(args, new PluginUtil.MyCallbackContext("dummy-" + map.hashCode(), webView) {
@@ -325,6 +324,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
map.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {
@Override
public void onCameraIdle() {
+ mapView.setVisibility(View.INVISIBLE);
PluginMap.this.onCameraIdle();
map.setOnCameraIdleListener(PluginMap.this);
Handler handler = new Handler();
@@ -345,6 +345,8 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
handler.postDelayed(new AdjustInitCamera(params), 500);
}
});
+ } else {
+ mapView.setVisibility(View.VISIBLE);
}
}
if (params.has("controls")) {
@@ -424,6 +426,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
e.printStackTrace();
}
map.moveCamera(CameraUpdateFactory.newCameraPosition(builder.build()));
+ mapView.setVisibility(View.VISIBLE);
//fitBounds(initCameraBounds, CAMERA_PADDING);
}

MODIFY
src/ios/GoogleMaps/CordovaGoogleMaps.m
src/ios/GoogleMaps/CordovaGoogleMaps.m
// Generate an instance of GMSMapView;
- GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:0
- longitude:0
- zoom:0
- bearing:0
- viewingAngle:0];
+ GMSCameraPosition *camera = nil;
+ int bearing = 0;
+ double angle = 0, zoom = 0;
+ NSDictionary *latLng = nil;
+ double latitude = 0;
+ double longitude = 0;
+ GMSCoordinateBounds *cameraBounds = nil;
+ NSDictionary *cameraOptions = [initOptions valueForKey:@"camera"];
+ if (cameraOptions) {
+
+ if ([cameraOptions valueForKey:@"bearing"]) {
+ bearing = (int)[[cameraOptions valueForKey:@"bearing"] integerValue];
+ } else {
+ bearing = 0;
+ }
+
+ if ([cameraOptions valueForKey:@"tilt"]) {
+ angle = [[cameraOptions valueForKey:@"tilt"] doubleValue];
+ } else {
+ angle = 0;
+ }
+
+ if ([cameraOptions valueForKey:@"zoom"] && [cameraOptions valueForKey:@"zoom"] != [NSNull null]) {
+ zoom = [[cameraOptions valueForKey:@"zoom"] doubleValue];
+ } else {
+ zoom = 0;
+ }
+ if ([cameraOptions objectForKey:@"target"]) {
+ NSString *targetClsName = [[cameraOptions objectForKey:@"target"] className];
+ if ([targetClsName isEqualToString:@"__NSCFArray"] || [targetClsName isEqualToString:@"__NSArrayM"] ) {
+ //--------------------------------------------
+ // cameraPosition.target = [
+ // new plugin.google.maps.LatLng(),
+ // ...
+ // new plugin.google.maps.LatLng()
+ // ]
+ //---------------------------------------------
+ int i = 0;
+ NSArray *latLngList = [cameraOptions objectForKey:@"target"];
+ GMSMutablePath *path = [GMSMutablePath path];
+ for (i = 0; i < [latLngList count]; i++) {
+ latLng = [latLngList objectAtIndex:i];
+ latitude = [[latLng valueForKey:@"lat"] doubleValue];
+ longitude = [[latLng valueForKey:@"lng"] doubleValue];
+ [path addLatitude:latitude longitude:longitude];
+ }
+
+ cameraBounds = [[GMSCoordinateBounds alloc] initWithPath:path];
+ //CLLocationCoordinate2D center = cameraBounds.center;
+
+ latitude = cameraBounds.center.latitude;
+ longitude = cameraBounds.center.longitude;
+ } else {
+ //------------------------------------------------------------------
+ // cameraPosition.target = new plugin.google.maps.LatLng();
+ //------------------------------------------------------------------
+
+ latLng = [cameraOptions objectForKey:@"target"];
+ latitude = [[latLng valueForKey:@"lat"] floatValue];
+ longitude = [[latLng valueForKey:@"lng"] floatValue];
+
+ }
+ }
+ }
+ camera = [GMSCameraPosition cameraWithLatitude:latitude
+ longitude:longitude
+ zoom: zoom
+ bearing: bearing
+ viewingAngle: angle];
+ [pluginMap.mapCtrl.view setHidden:YES];
pluginMap.mapCtrl.map = [GMSMapView mapWithFrame:rect camera:camera];
//mapType

MODIFY
src/ios/GoogleMaps/PluginMap.m
src/ios/GoogleMaps/PluginMap.m
// case: plugin.google.maps.getMap([options]) (no the mapDiv is given)
//-----------------------------------------------------------------------
[self setOptions:command];
+ [self.mapCtrl.view setHidden:NO];
//[self.mapCtrl.view setHidden:true];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithRegion:self.mapCtrl.map.projection.visibleRegion];
[self.mapCtrl.map cameraForBounds:bounds insets:paddingUiEdgeInsets];
}
+ [self.mapCtrl.view setHidden:NO];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithRegion:self.mapCtrl.map.projection.visibleRegion];
[self.mapCtrl.map cameraForBounds:bounds insets:paddingUiEdgeInsets];
+ [self.mapCtrl.view setHidden:NO];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
});
});
} else {
+ [self.mapCtrl.view setHidden:NO];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
NSDictionary *cameraOpts = [initOptions objectForKey:@"camera"];
[self _changeCameraPosition:@"moveCamera" params:cameraOpts command:command];
} else {
+ [self.mapCtrl.view setHidden:NO];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

Update: hide the map view when you set the camera option for Map.getMap() method (#1570)