context can now be given as argument in StyleMap.addUniqueValueRules()
this, for example, allows user to access to properties that are not part of the feature attributes. r=elemoine (closes #1548) git-svn-id: http://svn.openlayers.org/trunk/openlayers@7216 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -173,6 +173,9 @@ OpenLayers.Rule = OpenLayers.Class({
|
||||
if (!context) {
|
||||
context = feature.attributes || feature.data;
|
||||
}
|
||||
if (typeof this.context == "function") {
|
||||
context = this.context(feature);
|
||||
}
|
||||
return context;
|
||||
},
|
||||
|
||||
|
||||
@@ -130,12 +130,17 @@ OpenLayers.StyleMap = OpenLayers.Class({
|
||||
* rules for
|
||||
* symbolizers - {Object} Hash of symbolizers, keyed by the desired
|
||||
* property values
|
||||
* context - {Object} An optional object with properties that
|
||||
* symbolizers' property values should be evaluated
|
||||
* against. If no context is specified, feature.attributes
|
||||
* will be used
|
||||
*/
|
||||
addUniqueValueRules: function(renderIntent, property, symbolizers) {
|
||||
addUniqueValueRules: function(renderIntent, property, symbolizers, context) {
|
||||
var rules = [];
|
||||
for (var value in symbolizers) {
|
||||
rules.push(new OpenLayers.Rule({
|
||||
symbolizer: symbolizers[value],
|
||||
context: context,
|
||||
filter: new OpenLayers.Filter.Comparison({
|
||||
type: OpenLayers.Filter.Comparison.EQUAL_TO,
|
||||
property: property,
|
||||
|
||||
Reference in New Issue
Block a user