From ec51720696e16d3b9c3286b9fc3522ece39277e0 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 18 Jun 2014 17:01:56 -0300 Subject: Adding showPolygonFromQueryMultiple() --- gmap_arcgis.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index abdbb64..054c8c7 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -607,6 +607,39 @@ function gmapArcgis(config) { }); }, + // Show a polygon resulting from the given query in multiple layers + showPolygonFromQueryMultiple: function (params, name, layers) { + var self = this; + var max = 2; + var where = params.where; + + // Format where clause for ajax request + where = where.replace(/=/g, '%3D'); + where = where.replace(/ /g, '+'); + + // First find out in which layers there are results + for (var n in layers) { + var layer = n; + var args = jQuery.extend(true, {}, params); + var url = URL_ARCGIS_TIS + '/' + layer + '/query?where=' + where + '&f=pjson'; + + // A closure here keeps the right layer to the async response + (function(layer, args) { + $.ajax({ + type: 'get', + url: url, + dataType: 'jsonp', + success: function (response) { + if (response.features != undefined && response.features.length != '0') { + args.uri += '/' + layer; + self.showPolygonFromQuery(args, name); + } + } + }); + })(layer, args); + } + }, + // Close all registered infoWindows closeInfoWindows: function() { overlays = [ 'layers', 'markers' ]; -- cgit v1.2.3