From 7dab7dfcefc3b9f5355e420e328ab14cf58186af Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 2 Apr 2013 16:00:57 -0300 Subject: Working code for clickable polygons (2) --- gmap_arcgis.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'gmap_arcgis.js') diff --git a/gmap_arcgis.js b/gmap_arcgis.js index 190f9b3..c1023c9 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -46,6 +46,25 @@ 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(); + }); + } + else { + google.maps.event.addListener(params.overlay.getMapService(), 'update', function() { + params.callback(this.map, params) ; this.unblockUI(); + }); + } + + return params.overlay; + }, + + // Add an identify callback to a layer + identifyPolygon: function(params) { // See https://google-maps-utility-library-v3.googlecode.com/svn/trunk/arcgislink/examples/identify.js if (typeof params.identify != 'undefined') { var self = this; @@ -62,20 +81,6 @@ function gmapArcgis(config) { }); }); } - - 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(); - }); - } - else { - google.maps.event.addListener(params.overlay.getMapService(), 'update', function() { - params.callback(this.map, params) ; this.unblockUI(); - }); - } - - return params.overlay; }, // Add a KML to the map @@ -107,9 +112,9 @@ function gmapArcgis(config) { addLayers: function(element) { this.config['layers'][element].opacity = this.defaultOpacity(element); - // TODO: add identify listener if (typeof this.config['layers'][element].overlay != 'undefined') { this.config['layers'][element].overlay.setOpacity(this.config['layers'][element].opacity); + this.identifyPolygon(this.config['layers'][element]); this.unblockUI(); return; } -- cgit v1.2.3