From 24adf1e5de21777c1a2f94b0adbe0ae7216d8e18 Mon Sep 17 00:00:00 2001 From: Silvio Date: Tue, 2 Apr 2013 17:29:25 -0300 Subject: Identify: sort results by layer --- gmap_arcgis.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gmap_arcgis.js b/gmap_arcgis.js index c1023c9..89193f7 100644 --- a/gmap_arcgis.js +++ b/gmap_arcgis.js @@ -74,9 +74,26 @@ function gmapArcgis(config) { params.identify.width = self.map.getDiv().offsetWidth; params.identify.height = self.map.getDiv().offsetHeight; - params.service.identify(params.identify, function(results, err) { + params.service.identify(params.identify, function(identify, err) { if (!err) { - params.identify.callback(results, err); + var layers = { }; + var result = null; + var layerId = null; + + // Sort results by layer + for (var i in identify.results) { + result = identify.results[i]; + layerId = result.layerId; + + if (layers[layerId] == undefined) { + layers[layerId] = [ result ]; + } + else { + layers[layerId].push(result); + } + } + + params.identify.callback(layers, err); } }); }); -- cgit v1.2.3