Implement `preferences.gestureBounds` option
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.4.2-beta-20180901-2335" 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.4.2-beta-20180910-1917" 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">
<runs/>

MODIFY
src/android/plugin/google/maps/PluginMap.java
src/android/plugin/google/maps/PluginMap.java
@@ -393,6 +393,18 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
map.setMaxZoomPreference((float)zoom.getDouble("maxZoom"));
}
}
+
+
+ if (preferences.has("gestureBounds")) {
+ Object target = preferences.get("gestureBounds");
+ @SuppressWarnings("rawtypes")
+ Class targetClass = target.getClass();
+ if ("org.json.JSONArray".equals(targetClass.getName())) {
+ JSONArray points = preferences.getJSONArray("gestureBounds");
+ LatLngBounds bounds = PluginUtil.JSONArray2LatLngBounds(points);
+ map.setLatLngBoundsForCameraTarget(bounds);
+ }
+ }
}
// Set event listener
@@ -1298,6 +1310,23 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
map.setMaxZoomPreference((float)zoom.getDouble("maxZoom"));
}
}
+
+
+ if (preferences.has("gestureBounds")) {
+ Object target = preferences.get("gestureBounds");
+ @SuppressWarnings("rawtypes")
+ Class targetClass = target.getClass();
+ if ("org.json.JSONArray".equals(targetClass.getName())) {
+ JSONArray points = preferences.getJSONArray("gestureBounds");
+ if (points.length() > 0) {
+ LatLngBounds bounds = PluginUtil.JSONArray2LatLngBounds(points);
+ map.setLatLngBoundsForCameraTarget(bounds);
+ } else {
+ map.setLatLngBoundsForCameraTarget(null);
+ }
+ }
+ }
+
}
//gestures

MODIFY
src/ios/GoogleMaps/PluginMap.m
src/ios/GoogleMaps/PluginMap.m
[self.mapCtrl.map setMinZoom:minZoom maxZoom:maxZoom];
}
+
+ // gestureBounds
+ if ([preferences valueForKey:@"gestureBounds"] != nil) {
+ NSDictionary *latLng = nil;
+ double latitude, longitude;
+ int i = 0;
+ NSArray *latLngList = [preferences objectForKey:@"gestureBounds"];
+ 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];
+ }
+
+ [self.mapCtrl.map setCameraTargetBounds:[[GMSCoordinateBounds alloc] initWithPath:path]];
+ }
}
//styles

MODIFY
www/Map.js
www/Map.js
@@ -92,6 +92,13 @@ Map.prototype.getMap = function(meta, div, options) {
this.set("myLocationButton", options.controls.myLocationButton === true);
}
+ if (options.preferences && options.preferences.gestureBounds) {
+ if (utils.isArray(options.preferences.gestureBounds) ||
+ options.preferences.gestureBounds.type === "LatLngBounds") {
+ options.preferences.gestureBounds = common.convertToPositionArray(options.preferences.gestureBounds);
+ }
+ }
+
if (!common.isDom(div)) {
self.set("visible", false);
options = div;
@@ -278,6 +285,14 @@ Map.prototype.setOptions = function(options) {
this.set('camera_tilt', options.camera.tilt);
}
}
+
+ if (options.preferences && options.preferences.gestureBounds) {
+ if (utils.isArray(options.preferences.gestureBounds) ||
+ options.preferences.gestureBounds.type === "LatLngBounds") {
+ options.preferences.gestureBounds = common.convertToPositionArray(options.preferences.gestureBounds);
+ }
+ }
+
if (utils.isArray(options.styles)) {
options.styles = JSON.stringify(options.styles);
}

Implement `preferences.gestureBounds` option