Skip to content

Commit

Permalink
The variable POLYS has replaced by OVERLAYS. #124
Browse files Browse the repository at this point in the history
  • Loading branch information
wf9a5m75 committed Jul 11, 2014
1 parent 7a7e630 commit fad0341
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions www/googlemaps-cdv-plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* global cordova, plugin, CSSPrimitiveValue */
var PLUGIN_NAME = 'GoogleMaps';
var MARKERS = {};
var POLYS = {};
var KML_LAYERS = {};
var OVERLAYS = [];

Expand Down Expand Up @@ -133,7 +132,7 @@ App.prototype._onKmlEventForIOS = function(kmlLayerId, result, options) {
};

App.prototype._onOverlayEvent = function(eventName, hashCode) {
var overlay = POLYS[hashCode] || null;
var overlay = OVERLAYS[hashCode] || null;
if (overlay) {
overlay.trigger(eventName, overlay, this);
}
Expand Down Expand Up @@ -166,7 +165,6 @@ App.prototype._onKmlEvent = function(eventName, kmlLayerId, result, options) {

case "polygon":
overlay = new Polygon(result.id, options);
POLYS[result.id] = overlay;
args.push({
"type": "Polygon",
"object": overlay
Expand All @@ -175,15 +173,14 @@ App.prototype._onKmlEvent = function(eventName, kmlLayerId, result, options) {

case "polyline":
overlay = new Polyline(result.id, options);
POLYS[result.id] = overlay;
args.push({
"type": "Polyline",
"object": overlay
});
break;
}
if (overlay) {
OVERLAYS.push(overlay);
OVERLAYS[result.id] = overlay;
overlay.hashCode = result.hashCode;
kmlLayer.on("_REMOVE", function() {
overlay.remove();
Expand Down Expand Up @@ -412,9 +409,13 @@ App.prototype.getCameraPosition = function(callback) {
*/
App.prototype.clear = function(callback) {
var self = this;
for (var i = OVERLAYS.length; i > 0; i--) {
delete OVERLAYS[i - 1];
var overlayIDs = Object.keys(OVERLAYS);
var overlayId;
for (var i = 0; i < overlayIDs.length; i++) {
overlayId = overlayIDs[i];
delete OVERLAYS[overlayId];
}
OVERLAYS = {};
cordova.exec(function() {
if (typeof callback === "function") {
callback.call(self);
Expand Down Expand Up @@ -543,8 +544,7 @@ App.prototype.addCircle = function(circleOptions, callback) {

cordova.exec(function(result) {
var circle = new Circle(result.id, circleOptions);
POLYS[result.id] = circle;
OVERLAYS.push(circle);
OVERLAYS[result.id] = circle;
if (typeof circleOptions.onClick === "function") {
circle.on(plugin.google.maps.event.OVERLAY_CLICK, circleOptions.onClick);
}
Expand All @@ -567,8 +567,7 @@ App.prototype.addPolyline = function(polylineOptions, callback) {

cordova.exec(function(result) {
var polyline = new Polyline(result.id, polylineOptions);
POLYS[result.id] = polyline;
OVERLAYS.push(polyline);
OVERLAYS[result.id] = polyline;
if (typeof polylineOptions.onClick === "function") {
polyline.on(plugin.google.maps.event.OVERLAY_CLICK, polylineOptions.onClick);
}
Expand All @@ -592,8 +591,7 @@ App.prototype.addPolygon = function(polygonOptions, callback) {

cordova.exec(function(result) {
var polygon = new Polygon(result.id, polygonOptions);
POLYS[result.id] = polygon;
OVERLAYS.push(polygon);
OVERLAYS[result.id] = polygon;
if (typeof polygonOptions.onClick === "function") {
polygon.on(plugin.google.maps.event.OVERLAY_CLICK, polygonOptions.onClick);
}
Expand All @@ -620,8 +618,7 @@ App.prototype.addTileOverlay = function(tilelayerOptions, callback) {

cordova.exec(function(result) {
var tileOverlay = new TileOverlay(result.id, tilelayerOptions);
POLYS[result.id] = tileOverlay;
OVERLAYS.push(tileOverlay);
OVERLAYS[result.id] = tileOverlay;
if (typeof tilelayerOptions.onClick === "function") {
tileOverlay.on(plugin.google.maps.event.OVERLAY_CLICK, tilelayerOptions.onClick);
}
Expand All @@ -644,8 +641,7 @@ App.prototype.addGroundOverlay = function(groundOverlayOptions, callback) {
var pluginExec = function() {
cordova.exec(function(result) {
var groundOverlay = new GroundOverlay(result.id, groundOverlayOptions);
POLYS[result.id] = groundOverlay;
OVERLAYS.push(groundOverlay);
OVERLAYS[result.id] = groundOverlay;
if (typeof groundOverlayOptions.onClick === "function") {
groundOverlay.on(plugin.google.maps.event.OVERLAY_CLICK, groundOverlayOptions.onClick);
}
Expand Down

0 comments on commit fad0341

Please sign in to comment.