Bug fix: MarkerCluster not working in last version 2.0.9
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.9-beta-20170918-2233" 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.0.10-beta-20170919-0814" 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
www/Circle.js
www/Circle.js
@@ -13,6 +13,10 @@ var Circle = function(map, circleId, circleOptions, _exec) {
BaseClass.apply(this);
var self = this;
+ Object.defineProperty(self, "_isReady", {
+ value: true,
+ writable: false
+ });
Object.defineProperty(self, "map", {
value: map,
writable: false

MODIFY
www/Geocoder.js
www/Geocoder.js
@@ -20,7 +20,7 @@ Geocoder.geocode = function(geocoderRequest, callback) {
requests.on('insert_at', function(idx) {
var request = requests.getAt(idx);
request.idx = idx;
- exec(function(result) {
+ exec.call({_isReady: true}, function(result) {
if (!mvcResults) {
callback(result.results);
} else {

MODIFY
www/GroundOverlay.js
www/GroundOverlay.js
@@ -18,6 +18,10 @@ var GroundOverlay = function(map, groundOverlayId, groundOverlayOptions, _exec)
groundOverlayOptions.bounds = groundOverlayOptions.bounds || [];
groundOverlayOptions.anchor = groundOverlayOptions.anchor || [0, 0];
groundOverlayOptions.bearing = groundOverlayOptions.bearing || 0;
+ Object.defineProperty(self, "_isReady", {
+ value: true,
+ writable: false
+ });
Object.defineProperty(self, "id", {
value: groundOverlayId,
writable: false

MODIFY
www/KmlOverlay.js
www/KmlOverlay.js
@@ -14,6 +14,10 @@ var KmlOverlay = function(map, kmlOverlayId, kmlOverlayOptions, _exec) {
self._overlays = [];
//self.set("visible", kmlOverlayOptions.visible === undefined ? true : kmlOverlayOptions.visible);
//self.set("zIndex", kmlOverlayOptions.zIndex || 0);
+ Object.defineProperty(self, "_isReady", {
+ value: true,
+ writable: false
+ });
Object.defineProperty(self, "id", {
value: kmlOverlayId,
writable: false

MODIFY
www/Map.js
www/Map.js
@@ -43,7 +43,6 @@ var Map = function(id, _exec) {
value: id,
writable: false
});
- this._isReady = false;
self.on(event.MAP_CLICK, function() {
self.set("active_marker_id", undefined);
@@ -187,11 +186,11 @@ Map.prototype.getMap = function(mapId, div, options) {
// In order to work map.getVisibleRegion() correctly, wait a little.
//------------------------------------------------------------------------
setTimeout(function() {
- self.refreshLayout('getMap');
Object.defineProperty(self, "_isReady", {
value: true,
writable: false
});
+ self.refreshLayout();
self.trigger(event.MAP_READY, self);
}, 250);
}, self.errorHandler, 'CordovaGoogleMaps', 'getMap', args, {sync: true});
@@ -518,7 +517,6 @@ Map.prototype.getCameraPosition = function() {
*/
Map.prototype.remove = function(callback) {
var self = this;
- self._isReady = false;
var div = this.get('div');
if (div) {
while (div) {
@@ -788,10 +786,6 @@ Map.prototype.addKmlOverlay = function(kmlOverlayOptions, callback) {
delete self.OVERLAYS[kmlId];
kmlOverlay = undefined;
});
- Object.defineProperty(kmlOverlay, "_isReady", {
- value: true,
- writable: false
- });
if (typeof callback === "function") {
callback.call(self, kmlOverlay);
}
@@ -819,10 +813,6 @@ Map.prototype.addGroundOverlay = function(groundOverlayOptions, callback) {
delete self.OVERLAYS[result.id];
groundOverlay = undefined;
});
- Object.defineProperty(groundOverlay, "_isReady", {
- value: true,
- writable: false
- });
if (typeof callback === "function") {
callback.call(self, groundOverlay);
}
@@ -883,10 +873,6 @@ Map.prototype.addTileOverlay = function(tilelayerOptions, callback) {
delete self.OVERLAYS[result.id];
tileOverlay = undefined;
});
- Object.defineProperty(tileOverlay, "_isReady", {
- value: true,
- writable: false
- });
if (typeof callback === "function") {
callback.call(self, tileOverlay);
}
@@ -934,10 +920,6 @@ Map.prototype.addPolygon = function(polygonOptions, callback) {
delete self.OVERLAYS[result.id];
polygon = undefined;
});
- Object.defineProperty(polygon, "_isReady", {
- value: true,
- writable: false
- });
if (typeof callback === "function") {
callback.call(self, polygon);
}
@@ -967,10 +949,6 @@ Map.prototype.addPolyline = function(polylineOptions, callback) {
delete self.OVERLAYS[result.id];
polyline = undefined;
});
- Object.defineProperty(polyline, "_isReady", {
- value: true,
- writable: false
- });
if (typeof callback === "function") {
callback.call(self, polyline);
}
@@ -1001,11 +979,6 @@ Map.prototype.addCircle = function(circleOptions, callback) {
delete self.OVERLAYS[result.id];
circle = undefined;
});
-
- Object.defineProperty(circle, "_isReady", {
- value: true,
- writable: false
- });
if (typeof callback === "function") {
callback.call(self, circle);
}
@@ -1032,10 +1005,6 @@ Map.prototype.addMarker = function(markerOptions, callback) {
marker = undefined;
});
- Object.defineProperty(marker, "_isReady", {
- value: true,
- writable: false
- });
if (typeof callback === "function") {
callback.call(self, marker);
}
@@ -1114,10 +1083,6 @@ Map.prototype.addMarkerCluster = function(markerClusterOptions, callback) {
self.OVERLAYS[result.id] = markerCluster;
- Object.defineProperty(markerCluster, "_isReady", {
- value: true,
- writable: false
- });
if (typeof callback === "function") {
callback.call(self, markerCluster);
}

MODIFY
www/Marker.js
www/Marker.js
@@ -267,13 +267,13 @@ Marker.prototype.showInfoWindow = function() {
}
this.set("isInfoWindowVisible", true);
this.map.set("active_marker_id", this.id);
- exec(this, null, this.errorHandler, this.getPluginName(), 'showInfoWindow', [this.getId()], {sync: true});
+ exec.call(this, null, this.errorHandler, this.getPluginName(), 'showInfoWindow', [this.getId()], {sync: true});
return this;
};
Marker.prototype.hideInfoWindow = function() {
if (this.get("isInfoWindowVisible")) {
this.set("isInfoWindowVisible", false);
- exec(this, null, this.errorHandler, this.getPluginName(), 'hideInfoWindow', [this.getId()], {sync: true});
+ exec.call(this, null, this.errorHandler, this.getPluginName(), 'hideInfoWindow', [this.getId()], {sync: true});
}
return this;
};

MODIFY
www/MarkerCluster.js
www/MarkerCluster.js
@@ -22,6 +22,10 @@ var MarkerCluster = function(map, markerClusterId, markerClusterOptions, _exec)
var idxCount = Object.keys(markerClusterOptions.markerMap).length + 1;
var self = this;
+ Object.defineProperty(self, "_isReady", {
+ value: true,
+ writable: false
+ });
Object.defineProperty(self, "maxZoomLevel", {
value: markerClusterOptions.maxZoomLevel,
writable: false
@@ -1043,7 +1047,7 @@ MarkerCluster.prototype._redraw = function(params) {
return;
}
- exec(self, function() {
+ exec.call(self, function() {
self.trigger("nextTask");
}, self.errorHandler, self.getPluginName(), 'redrawClusters', [self.getId(), {
"resolution": resolution,

MODIFY
www/Polygon.js
www/Polygon.js
@@ -13,6 +13,10 @@ var Polygon = function(map, polygonId, polygonOptions, _exec) {
BaseClass.apply(this);
var self = this;
+ Object.defineProperty(self, "_isReady", {
+ value: true,
+ writable: false
+ });
Object.defineProperty(self, "map", {
value: map,
writable: false
@@ -32,14 +36,14 @@ var Polygon = function(map, polygonId, polygonOptions, _exec) {
var pointsProperty = common.createMvcArray(polygonOptions.points);
pointsProperty.on('set_at', function(index) {
var value = common.getLatLng(pointsProperty.getAt(index));
- exec(self, null, self.errorHandler, self.getPluginName(), 'setPointAt', [polygonId, index, value]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setPointAt', [polygonId, index, value]);
});
pointsProperty.on('insert_at', function(index) {
var value = common.getLatLng(pointsProperty.getAt(index));
- exec(self, null, self.errorHandler, self.getPluginName(), 'insertPointAt', [polygonId, index, value]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'insertPointAt', [polygonId, index, value]);
});
pointsProperty.on('remove_at', function(index) {
- exec(self, null, self.errorHandler, self.getPluginName(), 'removePointAt', [polygonId, index]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'removePointAt', [polygonId, index]);
});
Object.defineProperty(self, "points", {

MODIFY
www/Polyline.js
www/Polyline.js
@@ -13,6 +13,10 @@ var Polyline = function(map, polylineId, polylineOptions, _exec) {
BaseClass.apply(this);
var self = this;
+ Object.defineProperty(self, "_isReady", {
+ value: true,
+ writable: false
+ });
Object.defineProperty(self, "map", {
value: map,
writable: false
@@ -29,7 +33,7 @@ var Polyline = function(map, polylineId, polylineOptions, _exec) {
var pointsProperty = common.createMvcArray(polylineOptions.points);
pointsProperty.on('set_at', function(index) {
var value = common.getLatLng(pointsProperty.getAt(index));
- exec(self, null, self.errorHandler, self.getPluginName(), 'setPointAt', [polylineId, index, value]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setPointAt', [polylineId, index, value]);
});
pointsProperty.on('insert_at', function(index) {
var value = common.getLatLng(pointsProperty.getAt(index));

MODIFY
www/TileOverlay.js
www/TileOverlay.js
@@ -24,6 +24,10 @@ var TileOverlay = function(map, tileOverlayId, tileOverlayOptions, _exec) {
value: map,
writable: false
});
+ Object.defineProperty(self, "_isReady", {
+ value: true,
+ writable: false
+ });
//-----------------------------------------------
// Sets the initialize option to each property
//-----------------------------------------------
@@ -38,7 +42,7 @@ var TileOverlay = function(map, tileOverlayId, tileOverlayOptions, _exec) {
// Sets event listeners
//-----------------------------------------------
self.on("fadeIn_changed", function(oldValue, fadeIn) {
- exec(self, null, self.errorHandler, self.getPluginName(), 'setFadeIn', [self.getId(), fadeIn]);
+ exec.call(self, null, self.errorHandler, self.getPluginName(), 'setFadeIn', [self.getId(), fadeIn]);
});
self.on("opacity_changed", function(oldValue, opacity) {
exec.call(self, null, self.errorHandler, self.getPluginName(), 'setOpacity', [self.getId(), opacity]);

Bug fix: MarkerCluster not working in last version 2.0.9 #1751