diff options
-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); } }); }); |