From 594675dccca5fbc6055f5fc31870e0a3cf4a52e0 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 2 Apr 2013 15:51:56 -0300 Subject: Working code for clickable polygons --- gmap_arcgis.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index 07a4330..190f9b3 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -46,18 +46,18 @@ function gmapArcgis(config) { params.overlay.setMap(this.map); params.overlay.setOpacity(params.opacity); - // TODO: support for clickable polygons // See https://google-maps-utility-library-v3.googlecode.com/svn/trunk/arcgislink/examples/identify.js if (typeof params.identify != 'undefined') { - google.maps.event.addListener(this.map, 'click', function(point) { + var self = this; + params.identifyListener = google.maps.event.addListener(this.map, 'click', function(point) { params.identify.geometry = point.latLng; - params.identify.bounds = this.map.getBounds(); + params.identify.bounds = self.map.getBounds(); + params.identify.width = self.map.getDiv().offsetWidth; + params.identify.height = self.map.getDiv().offsetHeight; params.service.identify(params.identify, function(results, err) { - if (err) { - alert(err.message + err.details.join('\n')); - } else { - //addResultToMap(results, evt.latLng); + if (!err) { + params.identify.callback(results, err); } }); }); @@ -107,6 +107,7 @@ 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.unblockUI(); @@ -231,6 +232,10 @@ function gmapArcgis(config) { // Toggle layer visibility toggleLayers: function(element) { this.config['layers'][element].overlay.setOpacity(0); + + if (this.config['layers'][element].identifyListener != undefined) { + google.maps.event.removeListener(this.config['layers'][element].identifyListener); + } }, // Toggle marker visibility -- cgit v1.2.3