From 08c9b141ae506468cd781845f8edea2cb5a1dec5 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 31 Jul 2013 16:45:35 -0300 Subject: Fixing listeners on showPolygon() --- gmap_arcgis.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index bc67623..19e06a5 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -115,6 +115,7 @@ function gmapArcgis(config) { // Add polygons from a given ArcGIS MapServer Layer showPolygon: function(params) { + var self = this; params.service = new gmaps.ags.MapService(params['uri']); params.overlay = new gmaps.ags.MapOverlay(params.service, { exportOptions: { @@ -124,24 +125,24 @@ function gmapArcgis(config) { }, }); - params.overlay.setMap(this.map); - params.overlay.setOpacity(params.opacity); - - this.identifyPolygon(params); - if (params.callback == undefined) { // Default callback: remove the blockUI once the layer is shown - google.maps.event.addListener(params.overlay.getMapService(), 'update', function() { - this.unblockUI(); + google.maps.event.addListener(params.overlay, 'drawend', function() { + self.unblockUI(); }); } else { - google.maps.event.addListener(params.overlay.getMapService(), 'update', function() { + google.maps.event.addListener(params.overlay, 'drawend', function() { params.callback(this.map, params); - this.unblockUI(); + self.unblockUI(); }); } + params.overlay.setMap(this.map); + params.overlay.setOpacity(params.opacity); + + this.identifyPolygon(params); + return params.overlay; }, -- cgit v1.2.3