From d53c62bf7d4839d456eeb21fede184688fec2160 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 9 Apr 2013 16:51:57 -0300 Subject: Adding showPolygonFromQuery method and layerDefinitions to showPolygon --- gmap_arcgis.js | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index 14c7bdf..1ecf56e 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -64,9 +64,10 @@ function gmapArcgis(config) { params.service = new gmaps.ags.MapService(params['uri']); params.overlay = new gmaps.ags.MapOverlay(params.service, { exportOptions: { - layerIds: params['layers'], - layerOption: 'show', - } + layerIds: params['layers'], + layerOption: 'show', + layerDefinitions: (params['layerDefinitions'] != undefined) ? params['layerDefinitions'] : { }, + }, }); params.overlay.setMap(this.map); @@ -89,6 +90,29 @@ function gmapArcgis(config) { return params.overlay; }, + // TODO: merge with fitToBoundsOfQuery + // Add polygons from a custom query + showPolygonFromQuery: function(params) { + var self = this; + var layer = new gmaps.ags.Layer(params.uri); + var query = { + returnGeometry: true, + geometryType: 'esriGeometryPolygon', + where: params.where, + outFields: '*', + }; + + layer.query(query, function(fset) { + var fs = fset.features; + var feature = fs[0]; + params.overlay = feature.geometry[0]; + + params.overlay.setMap(self.map); + }); + + 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 @@ -433,7 +457,8 @@ function gmapArcgis(config) { }, // Center and zoom map to fit the polygon resulting from a query - fitToBoundsOfQuery: function(params) { + // Optinally show the resulting polygon. + fitToBoundsOfQuery: function(params, show) { var self = this; var layer = new gmaps.ags.Layer(params.uri); var query = { @@ -452,6 +477,12 @@ function gmapArcgis(config) { self.map.setZoom(zoom); self.map.setCenter(center); + + if (show == true) { + feature.geometry[0].setMap(self.map); + } + + params.overlay = feature.geometry[0]; }); }, } -- cgit v1.2.3