Add: stopAnimation()
Fix: can't remove map while map.animateCamera() is running
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.6.3-20190808-1526" 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.6.3-20190930-1201" 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="Promise" src="www/Promise.js" />
<js-module name="BaseClass" src="www/BaseClass.js">

MODIFY
src/android/plugin/google/maps/PluginMap.java
src/android/plugin/google/maps/PluginMap.java
@@ -1752,6 +1752,24 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
});
}
+
+ /**
+ * Stop camera animation
+ * @param args
+ * @param callbackContext
+ * @throws JSONException
+ */
+ public void stopAnimation(JSONArray args, final CallbackContext callbackContext) throws JSONException {
+
+ this.activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ map.stopAnimation();
+ callbackContext.success();
+ }
+ });
+ }
+
/**
* Pan by the specified pixel
* @param args

MODIFY
src/browser/PluginMap.js
src/browser/PluginMap.js
@@ -419,6 +419,10 @@ PluginMap.prototype.setMyLocationEnabled = function(onSuccess) {
// stub
onSuccess();
};
+PluginMap.prototype.stopAnimation = function(onSuccess) {
+ // stub
+ onSuccess();
+};
PluginMap.prototype.animateCamera = function(onSuccess, onError, args) {
var self = this;

MODIFY
src/ios/GoogleMaps/PluginMap.h
src/ios/GoogleMaps/PluginMap.h
- (void)panBy:(CDVInvokedUrlCommand*)command;
- (void)getFocusedBuilding:(CDVInvokedUrlCommand*)command;
- (void)setActiveMarkerId:(CDVInvokedUrlCommand*)command;
+- (void)stopAnimation:(CDVInvokedUrlCommand*)command;
@end
-
-

MODIFY
src/ios/GoogleMaps/PluginMap.m
src/ios/GoogleMaps/PluginMap.m
}];
}];
}
+
+
+- (void)stopAnimation:(CDVInvokedUrlCommand*)command {
+
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ [self.mapCtrl.map.layer removeAllAnimations];
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+ }];
+
+}
@end

MODIFY
www/Map.js
www/Map.js
@@ -673,6 +673,17 @@ Map.prototype.getCameraPosition = function() {
return this.get('camera');
};
+/**
+ * Cancel the camera animation
+ * @return {CameraPosition}
+ */
+Map.prototype.stopAnimation = function() {
+ var self = this;
+ if (self._isReady) {
+ cordova_exec(null, null, self.__pgmId, 'stopAnimation', []);
+ }
+};
+
/**
* Remove the map completely.
*/
@@ -685,6 +696,7 @@ Map.prototype.remove = function(callback) {
value: true,
writable: false
});
+ self.stopAnimation();
self.trigger('remove');
// var div = self.get('div');

- Add: stopAnimation()
- Fix: can't remove map while map.animateCamera() is running #2682