"users should be able to customize the select style per feature": Created a !StyleMap class which stores all styles that are needed for a layer. Controls that need to render features differently can now just give a render intent (e.g. "default", "select" or "temporary") to the layer's drawFeature method, instead of having extra style informations like Control.!SelectFeature.selectStyle. Existing application that set layer.style or feature.style are still supported, but both of these style properties are now null by default. r=crschmidt,elemoine,tschaub (closes #1120)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6240 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -98,6 +98,12 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
* {Object} Default style for the layer
|
||||
*/
|
||||
style: null,
|
||||
|
||||
/**
|
||||
* Property: styleMap
|
||||
* {<OpenLayers.StyleMap>}
|
||||
*/
|
||||
styleMap: null,
|
||||
|
||||
/**
|
||||
* Property: renderers
|
||||
@@ -147,9 +153,6 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
OpenLayers.Layer.prototype.EVENT_TYPES
|
||||
);
|
||||
|
||||
var defaultStyle = OpenLayers.Feature.Vector.style['default'];
|
||||
this.style = OpenLayers.Util.extend({}, defaultStyle);
|
||||
|
||||
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
|
||||
|
||||
// allow user-set renderer, otherwise assign one
|
||||
@@ -163,6 +166,10 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
this.displayError();
|
||||
}
|
||||
|
||||
if (!this.styleMap) {
|
||||
this.styleMap = new OpenLayers.StyleMap();
|
||||
}
|
||||
|
||||
this.features = [];
|
||||
this.selectedFeatures = [];
|
||||
},
|
||||
@@ -312,7 +319,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
//give feature reference to its layer
|
||||
feature.layer = this;
|
||||
|
||||
if (!feature.style) {
|
||||
if (!feature.style && this.style) {
|
||||
feature.style = OpenLayers.Util.extend({}, this.style);
|
||||
}
|
||||
|
||||
@@ -403,21 +410,17 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>}
|
||||
* style - {Object}
|
||||
* style - {Object} Symbolizer hash or {String} renderIntent
|
||||
*/
|
||||
drawFeature: function(feature, style) {
|
||||
if(style == null) {
|
||||
if(feature.style) {
|
||||
style = feature.style;
|
||||
} else {
|
||||
style = this.style;
|
||||
if (typeof style != "object") {
|
||||
var renderIntent = typeof style == "string" ?
|
||||
style : feature.renderIntent;
|
||||
style = feature.style || this.style;
|
||||
if (!style) {
|
||||
style = this.styleMap.createSymbolizer(feature, renderIntent);
|
||||
}
|
||||
}
|
||||
|
||||
if (style && style.CLASS_NAME &&
|
||||
style.CLASS_NAME == "OpenLayers.Style") {
|
||||
style = style.createStyle(feature);
|
||||
}
|
||||
|
||||
this.renderer.drawFeature(feature, style);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user