Implement PluginPolygon.js
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.3.12-ext-20180820-1337" 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.3.12-ext-20180820-1409" 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/browser/PluginCircle.js
src/browser/PluginCircle.js
@@ -58,7 +58,6 @@ PluginCircle.prototype._create = function(onSuccess, onError, args) {
});
self.pluginMap.objects[circleId] = circle;
- self.pluginMap.objects['circle_property_' + circleId] = circleOpts;
onSuccess({
'id': circleId
@@ -179,7 +178,6 @@ PluginCircle.prototype.remove = function(onSuccess, onError, args) {
circle = undefined;
self.pluginMap.objects[overlayId] = undefined;
delete self.pluginMap.objects[overlayId];
- delete self.pluginMap.objects['circle_property_' + overlayId];
}
onSuccess();
};

MODIFY
src/browser/PluginGroundOverlay.js
src/browser/PluginGroundOverlay.js
@@ -112,6 +112,36 @@ PluginGroundOverlay.prototype.setBounds = function(onSuccess, onError, args) {
onSuccess();
};
+PluginGroundOverlay.prototype.setZIndex = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var zIndex = args[1];
+ var groundOverlay = self.pluginMap.objects[overlayId];
+ if (groundOverlay) {
+ groundOverlay.setZIndex(zIndex);
+ }
+ onSuccess();
+};
+
+PluginGroundOverlay.prototype.setClickable = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var groundOverlay = self.pluginMap.objects[overlayId];
+ if (groundOverlay) {
+ groundOverlay.setClickable(args[1]);
+ }
+ onSuccess();
+};
+PluginGroundOverlay.prototype.setVisible = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var groundOverlay = self.pluginMap.objects[overlayId];
+ if (groundOverlay) {
+ groundOverlay.setVisible(args[1]);
+ }
+ onSuccess();
+};
+
PluginGroundOverlay.prototype.remove = function(onSuccess, onError, args) {
var self = this;
var overlayId = args[0];
@@ -192,9 +222,6 @@ function CustomGroundOverlay(url, bounds, options) {
self.addListener('opacity_changed', function() {
img.style.opacity = self.get('opacity');
});
- self.addListener('zIndex_changed', function() {
- img.style.zIndex = self.get('zIndex');
- });
//---------------------------------------------------------
// Create a transparent rectangle above the groundOverlay,
@@ -209,10 +236,16 @@ function CustomGroundOverlay(url, bounds, options) {
'strokeOpacity': 0,
'zIndex': options.zIndex || 0
});
+ self.addListener('visible_changed', function() {
+ img.style.visibility = self.get('visible') ? 'visible' : 'hidden';
+ touchPolygon.setVisible(self.get('visible'));
+ });
+
self.addListener('zIndex_changed', function() {
touchPolygon.setOptions({
'zIndex': self.get('zIndex')
});
+ img.style.zIndex = self.get('zIndex');
});
touchPolygon.addListener('click', function(evt) {
@@ -298,6 +331,10 @@ CustomGroundOverlay.prototype.remove = function() {
google.maps.event.clearInstanceListeners(self.get('touchPolygon'));
};
+CustomGroundOverlay.prototype.setClickable = function(clickable) {
+ var self = this;
+ self.set('clickable', clickable);
+};
CustomGroundOverlay.prototype.setOpacity = function(opacity) {
var self = this;
@@ -319,6 +356,16 @@ CustomGroundOverlay.prototype.setOpacity = function(opacity) {
self.set("opacity", opacity);
};
+CustomGroundOverlay.prototype.setZIndex = function(zIndex) {
+ var self = this;
+ self.set("zIndex", zIndex);
+};
+
+CustomGroundOverlay.prototype.setVisible = function(visible) {
+ var self = this;
+ self.set("visible", visible);
+};
+
CustomGroundOverlay.prototype.setImage = function(url) {
var self = this;
self.set("url", url);

MODIFY
src/browser/PluginPolygon.js
src/browser/PluginPolygon.js
@@ -66,12 +66,53 @@ PluginPolygon.prototype._create = function(onSuccess, onError, args) {
});
self.pluginMap.objects[polygonId] = polygon;
- self.pluginMap.objects['polygon_property_' + polygonId] = polygonOpts;
onSuccess({
'id': polygonId
});
};
+
+PluginPolygon.prototype.setStrokeColor = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var polygon = self.pluginMap.objects[overlayId];
+ var strokeColor = args[1];
+ if (polygon) {
+ if (Array.isArray(strokeColor)) {
+ polygon.setOptions({
+ 'strokeColor': 'rgb(' + strokeColor[0] + ',' + strokeColor[1] + ',' + strokeColor[2] + ')',
+ 'strokeOpacity': strokeColor[3] / 256
+ });
+ }
+ }
+ onSuccess();
+};
+
+PluginPolygon.prototype.setStrokeWidth = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var width = args[1];
+ var polygon = self.pluginMap.objects[overlayId];
+ if (polygon) {
+ polygon.setOptions({
+ 'strokeWeight': width
+ });
+ }
+ onSuccess();
+};
+
+
+PluginPolygon.prototype.setZIndex = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var zIndex = args[1];
+ var polygon = self.pluginMap.objects[overlayId];
+ if (polygon) {
+ polygon.setZIndex(zIndex);
+ }
+ onSuccess();
+};
+
PluginPolygon.prototype.setPoints = function(onSuccess, onError, args) {
var self = this,
polygonId = args[0],
@@ -86,6 +127,19 @@ PluginPolygon.prototype.setPoints = function(onSuccess, onError, args) {
onSuccess();
};
+PluginPolygon.prototype.setClickable = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var clickable = args[1];
+ var polygon = self.pluginMap.objects[overlayId];
+ if (polygon) {
+ polygon.setOptions({
+ 'clickable': clickable === true
+ });
+ }
+ onSuccess();
+};
+
PluginPolygon.prototype.setVisible = function(onSuccess, onError, args) {
var self = this;
var overlayId = args[0];
@@ -95,6 +149,27 @@ PluginPolygon.prototype.setVisible = function(onSuccess, onError, args) {
}
onSuccess();
};
+
+PluginPolygon.prototype.setGeodesic = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var polygon = self.pluginMap.objects[overlayId];
+ if (polygon) {
+ polygon.setGeodesic(args[1] === true)
+ }
+ onSuccess();
+};
+PluginPolygon.prototype.insertPointAt = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var polygon = self.pluginMap.objects[overlayId];
+ if (polygon) {
+ var index = args[1];
+ var latLng = new google.maps.LatLng(args[2].lat, args[2].lng);
+ polygon.getPath().insertAt(index, latLng);
+ }
+ onSuccess();
+};
PluginPolygon.prototype.setPointAt = function(onSuccess, onError, args) {
var self = this;
var overlayId = args[0];
@@ -102,9 +177,17 @@ PluginPolygon.prototype.setPointAt = function(onSuccess, onError, args) {
if (polygon) {
var index = args[1];
var latLng = new google.maps.LatLng(args[2].lat, args[2].lng);
- var opts = self.pluginMap.objects['polygon_property_' + overlayId];
- var strokePath = opts.paths.getAt(0);
- strokePath.setAt(index, latLng);
+ polygon.getPath().setAt(index, latLng);
+ }
+ onSuccess();
+};
+PluginPolygon.prototype.removePointAt = function(onSuccess, onError, args) {
+ var self = this;
+ var overlayId = args[0];
+ var polygon = self.pluginMap.objects[overlayId];
+ if (polygon) {
+ var index = args[1];
+ polygon.getPath().removeAt(index, latLng);
}
onSuccess();
};
@@ -119,7 +202,6 @@ PluginPolygon.prototype.remove = function(onSuccess, onError, args) {
polygon = undefined;
self.pluginMap.objects[overlayId] = undefined;
delete self.pluginMap.objects[overlayId];
- delete self.pluginMap.objects['polygon_property_' + overlayId];
}
onSuccess();
};

MODIFY
www/GroundOverlay.js
www/GroundOverlay.js
@@ -93,6 +93,9 @@ GroundOverlay.prototype.setOpacity = function (opacity) {
this.set('opacity', opacity);
};
GroundOverlay.prototype.setBearing = function (bearing) {
+ if (bearing > 360) {
+ bearing = bearing - Math.floor(bearing / 360) * 360;
+ }
this.set('bearing', bearing);
};

Implement PluginPolygon.js