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:
@@ -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
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user