From f873a1d5a193f98659235708777e1acc64a4b03c Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 1 Apr 2013 19:39:56 -0300 Subject: Sketching the identify feature --- gmap_arcgis.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'gmap_arcgis.js') diff --git a/gmap_arcgis.js b/gmap_arcgis.js index d0bd721..07a4330 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -33,10 +33,10 @@ function gmapArcgis(config) { } }, - // TODO: support for clickable polygons // Add polygons from a given ArcGIS MapServer Layer showPolygon: function(params, store) { - params.overlay = new gmaps.ags.MapOverlay(params['uri'], { + params.service = new gmaps.ags.MapService(params['uri']); + params.overlay = new gmaps.ags.MapOverlay(params.service, { exportOptions: { layerIds: params['layers'], layerOption: 'show', @@ -46,6 +46,23 @@ 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) { + params.identify.geometry = point.latLng; + params.identify.bounds = this.map.getBounds(); + + params.service.identify(params.identify, function(results, err) { + if (err) { + alert(err.message + err.details.join('\n')); + } else { + //addResultToMap(results, evt.latLng); + } + }); + }); + } + if (params.callback == undefined) { // Default callback: remove the blockUI once the layer is shown google.maps.event.addListener(params.overlay.getMapService(), 'update', function() { @@ -60,7 +77,7 @@ function gmapArcgis(config) { return params.overlay; }, - + // Add a KML to the map showKML: function(element) { if (typeof this.config['kmls'][element].overlay == 'undefined') { @@ -99,7 +116,7 @@ function gmapArcgis(config) { if (this.config['layers'][element].overlayTime != undefined) { this.showOverlay(this.config['layers'][element].overlayTime); } - + this.config['layers'][element].overlay = this.showPolygon(this.config['layers'][element]); }, -- cgit v1.2.3