getFeatures method and featureInfo templates
To avoid surprises for application developers, this change creates a new getFeatures method. So it is clear now beforehand whether features or feature info markup is returned. The result is now also grouped by layer, so application developers always have a link between a layer and the feature info it returns. To make getFeatureInfo return markup for vector layers, this change also adds a featureInfoFunction property to the vector layer, which gives developers full control over how features are rendered to feature info markup.
This commit is contained in:
@@ -9,12 +9,26 @@
|
||||
* @typedef {Object} ol.GetFeatureInfoOptions
|
||||
* @property {ol.Pixel} pixel Pixel coordinate relative to the map viewport.
|
||||
* @property {Array.<ol.layer.Layer>|undefined} layers Layers to restrict the
|
||||
* query to. All layers will be queried if not provided.
|
||||
* @property {function(Array.<ol.Feature|string>)} success Callback for
|
||||
* query to. All map layers will be queried if not provided.
|
||||
* @property {function(Array.<string|undefined>)} success Callback for
|
||||
* successful queries. The passed argument is the resulting feature
|
||||
* information. Layers that are able to provide attribute data will put
|
||||
* ol.Feature instances, other layers will put a string which can either
|
||||
* be plain text or markup.
|
||||
* information for each layer, with array indices being the same as in the
|
||||
* passed `layers` array or in the layer collection as returned from
|
||||
* `ol.Map#getLayers()` if no `layers` were provided.
|
||||
* @property {function(Object)|undefined} error Callback for unsuccessful
|
||||
* queries.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.GetFeaturesOptions
|
||||
* @property {ol.Pixel} pixel Pixel coordinate relative to the map viewport.
|
||||
* @property {Array.<ol.layer.Layer>|undefined} layers Layers to restrict the
|
||||
* query to. All layers will be queried if not provided.
|
||||
* @property {function(Array.<Array.<ol.Feature|undefined>>)} success Callback
|
||||
* for successful queries. The passed argument is the resulting features for
|
||||
* each layer, with array indices being the same as in the passed `layers`
|
||||
* array or in the layer collection as returned from `ol.Map#getLayers()` if
|
||||
* no layers were provided.
|
||||
* @property {function(Object)|undefined} error Callback for unsuccessful
|
||||
* queries.
|
||||
*/
|
||||
@@ -287,6 +301,10 @@
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.layer.VectorLayerOptions
|
||||
* @property {function(Array.<ol.Feature>):string|
|
||||
* undefined} featureInfoFunction Function to render an array of features
|
||||
* into feature info markup. If not provided, a comma separated list the
|
||||
* unique ids of the resulting features will be returned.
|
||||
* @property {number|undefined} opacity Opacity. 0-1. Default is 1.
|
||||
* @property {ol.source.Source} source Source for this layer.
|
||||
* @property {ol.style.Style|undefined} style Style.
|
||||
|
||||
Reference in New Issue
Block a user