(Browser) Fix: the methods manipulate hole property do not work correctly
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.4.4-beta-20180913-1200" 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.4-beta-20180913-1300" 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/browser/PluginPolygon.js
src/browser/PluginPolygon.js
@@ -36,6 +36,7 @@ PluginPolygon.prototype._create = function(onSuccess, onError, args) {
});
polygonOpts.paths.push(strokePath);
+
if (Array.isArray(pluginOptions.holes)) {
pluginOptions.holes.forEach(function(hole) {
var holeMvc = new google.maps.MVCArray();
@@ -247,7 +248,7 @@ PluginPolygon.prototype.setHoles = function(onSuccess, onError, args) {
PluginPolygon.prototype.insertPointOfHoleAt = function(onSuccess, onError, args) {
var self = this,
overlayId = args[0],
- holeIndex = args[1],
+ holeIndex = args[1] + 1, // idx=0 is for outter vertixes
pointIndex = args[2],
position = args[3],
polygon = self.pluginMap.objects[overlayId];
@@ -255,7 +256,16 @@ PluginPolygon.prototype.insertPointOfHoleAt = function(onSuccess, onError, args)
if (polygon) {
var index = args[1];
var latLng = new google.maps.LatLng(position.lat, position.lng);
- polygon.getPaths().getAt(holeIndex).insertAt(pointIndex, latLng);
+ var paths = polygon.getPaths();
+ var hole = null;
+ if (holeIndex < paths.getLength()) {
+ hole = paths.getAt(holeIndex);
+ }
+ if (!hole) {
+ hole = new google.maps.MVCArray();
+ paths.push(hole);
+ }
+ hole.insertAt(pointIndex, latLng);
}
onSuccess();
};
@@ -263,7 +273,7 @@ PluginPolygon.prototype.insertPointOfHoleAt = function(onSuccess, onError, args)
PluginPolygon.prototype.setPointOfHoleAt = function(onSuccess, onError, args) {
var self = this,
overlayId = args[0],
- holeIndex = args[1],
+ holeIndex = args[1] + 1,
pointIndex = args[2],
position = args[3],
polygon = self.pluginMap.objects[overlayId];
@@ -279,7 +289,7 @@ PluginPolygon.prototype.setPointOfHoleAt = function(onSuccess, onError, args) {
PluginPolygon.prototype.removePointOfHoleAt = function(onSuccess, onError, args) {
var self = this,
overlayId = args[0],
- holeIndex = args[1],
+ holeIndex = args[1] + 1,
pointIndex = args[2],
polygon = self.pluginMap.objects[overlayId];
@@ -293,7 +303,7 @@ PluginPolygon.prototype.removePointOfHoleAt = function(onSuccess, onError, args)
PluginPolygon.prototype.insertHoleAt = function(onSuccess, onError, args) {
var self = this,
overlayId = args[0],
- holeIndex = args[1],
+ holeIndex = args[1] + 1,
vertixes = args[2],
polygon = self.pluginMap.objects[overlayId];
@@ -312,7 +322,7 @@ PluginPolygon.prototype.insertHoleAt = function(onSuccess, onError, args) {
PluginPolygon.prototype.setHoleAt = function(onSuccess, onError, args) {
var self = this,
overlayId = args[0],
- holeIndex = args[1],
+ holeIndex = args[1] + 1,
vertixes = args[2],
polygon = self.pluginMap.objects[overlayId];
@@ -330,7 +340,7 @@ PluginPolygon.prototype.setHoleAt = function(onSuccess, onError, args) {
PluginPolygon.prototype.removeHoleAt = function(onSuccess, onError, args) {
var self = this,
overlayId = args[0],
- holeIndex = args[1],
+ holeIndex = args[1] + 1,
polygon = self.pluginMap.objects[overlayId];
if (polygon) {

(Browser) Fix: the methods manipulate hole property do not work correctly