diff options
author | Silvio <silvio@socioambiental.org> | 2013-04-02 17:29:25 -0300 |
---|---|---|
committer | Silvio <silvio@socioambiental.org> | 2013-04-02 17:29:25 -0300 |
commit | 24adf1e5de21777c1a2f94b0adbe0ae7216d8e18 (patch) | |
tree | b69ae465821507fe7e8d7a8e6fb3e77f2a654a69 | |
parent | 7dab7dfcefc3b9f5355e420e328ab14cf58186af (diff) | |
download | gmap_arcgis_js-24adf1e5de21777c1a2f94b0adbe0ae7216d8e18.tar.gz gmap_arcgis_js-24adf1e5de21777c1a2f94b0adbe0ae7216d8e18.tar.bz2 |
Identify: sort results by layer
-rw-r--r-- | gmap_arcgis.js | 21 |
1 files 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); } }); }); |