(Android / iOS) Prevent null pointer error
MODIFY
src/android/plugin/google/maps/CordovaGoogleMaps.java
src/android/plugin/google/maps/CordovaGoogleMaps.java
@@ -311,14 +311,26 @@ public class CordovaGoogleMaps extends CordovaPlugin implements ViewTreeObserver
}
public void pause(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
+ if (mPluginLayout == null) {
+ callbackContext.success();
+ return;
+ }
mPluginLayout.isSuspended = true;
callbackContext.success();
}
public void resume(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
+ if (mPluginLayout == null) {
+ callbackContext.success();
+ return;
+ }
mPluginLayout.isSuspended = false;
callbackContext.success();
}
public void clearHtmlElements(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
+ if (mPluginLayout == null) {
+ callbackContext.success();
+ return;
+ }
mPluginLayout.clearHtmlElements();
callbackContext.success();
}

MODIFY
src/ios/GoogleMaps/CordovaGoogleMaps.m
src/ios/GoogleMaps/CordovaGoogleMaps.m
}
- (void)clearHtmlElements:(CDVInvokedUrlCommand *)command {
[self.executeQueue addOperationWithBlock:^{
+ if (self.pluginLayer != nil) {
[self.pluginLayer clearHTMLElements];
+ }
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}
- (void)resume:(CDVInvokedUrlCommand *)command {
- self.pluginLayer.isSuspended = NO;
+ if (self.pluginLayer != nil) {
+ self.pluginLayer.isSuspended = false;
+ }
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void)pause:(CDVInvokedUrlCommand *)command {
- self.pluginLayer.isSuspended = YES;
+ if (self.pluginLayer != nil) {
+ self.pluginLayer.isSuspended = true;
+ }
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
NSDictionary *elements = [command.arguments objectAtIndex:0];
+ if (self.pluginLayer != nil) {
[self.pluginLayer putHTMLElements:elements];
+ }
/*
if (self.pluginLayer.needUpdatePosition) {
self.pluginLayer.needUpdatePosition = NO;

(Android / iOS) Prevent null pointer error