Method for getting both feature id and data.

Having to call two methods to get complete feature information (id and data) is cumbersome.  The `getFeatureInfo` method returns an object with both feature id and data.
This commit is contained in:
Tim Schaub
2012-02-28 05:37:28 -07:00
parent 19a11561e8
commit 4d31a3ed3a
6 changed files with 75 additions and 54 deletions
+6 -6
View File
@@ -33,7 +33,7 @@
* var control = new OpenLayers.Control.UTFGrid({
* layers: [world_utfgrid],
* handlerMode: 'move',
* callback: function(dataLookup) {
* callback: function(infoLookup) {
* // do something with returned data
*
* }
@@ -175,14 +175,14 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
var layers = this.findLayers();
if (layers.length > 0) {
var dataLookup = {};
var infoLookup = {};
var layer, idx;
for (var i=0, len=layers.length; i<len; i++) {
layer = layers[i];
idx = this.map.layers.indexOf(layer);
dataLookup[idx] = layer.getFeatureData(lonLat);
infoLookup[idx] = layer.getFeatureInfo(lonLat);
}
this.callback(dataLookup); // perhaps pass tile, lonLat?
this.callback(infoLookup); // perhaps pass tile, lonLat?
}
},
@@ -192,12 +192,12 @@ OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
* includes data in one of the configured UTFGrid layers.
*
* Parameters:
* dataLookup - {Object} Keys of this object are layer indexes and can be
* infoLookup - {Object} Keys of this object are layer indexes and can be
* used to resolve a layer in the map.layers array. The structure of
* the property values depend on the data included in the underlying
* UTFGrid and may be any valid JSON type.
*/
callback: function(dataLookup) {
callback: function(infoLookup) {
// to be provided in the constructor
},