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:
@@ -237,22 +237,26 @@ OpenLayers.Layer.UTFGrid = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
},
|
||||
|
||||
/**
|
||||
* APIProperty: getFeatureData
|
||||
* Get feature data from UTFGrid associated with a map location.
|
||||
* APIProperty: getFeatureInfo
|
||||
* Get details about a feature associated with a map location. The object
|
||||
* returned will have id and data properties. If the given location
|
||||
* doesn't correspond to a feature, null will be returned.
|
||||
*
|
||||
* Parameters:
|
||||
* location - {<OpenLayers.LonLat>} map location
|
||||
*
|
||||
* Returns:
|
||||
* {Object} The UTFGrid data corresponding to the given map location.
|
||||
* {Object} Object representing the feature id and UTFGrid data
|
||||
* corresponding to the given map location. Returns null if the given
|
||||
* location doesn't hit a feature.
|
||||
*/
|
||||
getFeatureData: function(location) {
|
||||
var data;
|
||||
var info = this.getTileInfo(location);
|
||||
if (info.tile) {
|
||||
data = info.tile.getFeatureData(info.i, info.j);
|
||||
getFeatureInfo: function(location) {
|
||||
var info = null;
|
||||
var tileInfo = this.getTileInfo(location);
|
||||
if (tileInfo.tile) {
|
||||
info = tileInfo.tile.getFeatureInfo(tileInfo.i, tileInfo.j);
|
||||
}
|
||||
return data;
|
||||
return info;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -263,10 +267,11 @@ OpenLayers.Layer.UTFGrid = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
* location - {<OpenLayers.LonLat>} map location
|
||||
*
|
||||
* Returns:
|
||||
* {Object} The feature identifier corresponding to the given map location.
|
||||
* {String} The feature identifier corresponding to the given map location.
|
||||
* Returns null if the location doesn't hit a feature.
|
||||
*/
|
||||
getFeatureId: function(location) {
|
||||
var id;
|
||||
var id = null;
|
||||
var info = this.getTileInfo(location);
|
||||
if (info.tile) {
|
||||
id = info.tile.getFeatureId(info.i, info.j);
|
||||
|
||||
Reference in New Issue
Block a user