for (var i = 0; i != features_all.length; ++i) {
var feature = features_all[i];
feature.geometry.transform(EPSG4326, EPSG3857);
- if (feature.geometry.CLASS_NAME == 'OpenLayers.Geometry.Point') {
- if (feature.attributes.type == 'sledrun') {
- var condition = feature.attributes.condition;
- if (condition === undefined) condition = 0;
- feature.attributes.externalGraphic = 'bahnzustand' + condition + '_0.png';
- feature.attributes.graphicWidth = 17;
- feature.attributes.graphicHeight = 17;
- feature.attributes.graphicXOffset = -8;
- feature.attributes.graphicYOffset = -8;
- } else {
- var name = POINT_NAME[feature.attributes.type];
- if (feature.attributes.type == 'point' || name === undefined)
- feature.attributes.externalGraphic = 'gmap.png';
- else
- feature.attributes.externalGraphic = 'gmap' + name + '.png';
- feature.attributes.graphicWidth = 20;
- feature.attributes.graphicHeight = 34;
- feature.attributes.graphicXOffset = -10;
- feature.attributes.graphicYOffset = -33;
- }
- features_point.push(feature);
- } else features_path.push(feature);
+ if (feature.geometry instanceof OpenLayers.Geometry.Point) features_point.push(feature);
+ else features_path.push(feature);
}
// point layer
// -----------
+ var filter_point_sledrun = new OpenLayers.Filter.Comparison({
+ type: OpenLayers.Filter.Comparison.EQUAL_TO,
+ property: 'type',
+ value: 'sledrun'
+ });
+
var layer_point = new OpenLayers.Layer.Vector("Point", {
styleMap: new OpenLayers.StyleMap({
'default': new OpenLayers.Style({
- externalGraphic: '/vorlagen/${externalGraphic}',
- graphicWidth: '${graphicWidth}',
- graphicHeight: '${graphicHeight}',
- graphicXOffset: '${graphicXOffset}',
- graphicYOffset: '${graphicYOffset}',
graphicZIndex: 12,
- backgroundGraphic: "/vorlagen/gmap_rodelbahn_c_s.png",
- backgroundWidth: 23,
- backgroundHeight: 23,
- backgroundXOffset: -8,
- backgroundYOffset: -8,
backgroundGraphicZIndex: 11,
- title: '${getTitle}'
+ }, {
+ context: {
+ // the following context functions should only be available in the rule that uses them,
+ // but the rule dependent contexts are ignored by OpenLayers (I think that's a bug)
+ getCondition: function(feature) {
+ if (feature.condition === undefined) return 0;
+ return feature.condition;
+ },
+ getSymbol: function(feature) {
+ var name = POINT_NAME[feature.attributes.type];
+ if (feature.attributes.type == 'point' || name === undefined) return '';
+ return name;
+ }
+ },
+ rules: [
+ new OpenLayers.Rule({
+ filter: filter_point_sledrun,
+ symbolizer: {
+ externalGraphic: '/vorlagen/bahnzustand${getCondition}_0.png',
+ graphicWidth: 17,
+ graphicHeight: 17,
+ graphicXOffset: -8,
+ graphicYOffset: -8,
+ backgroundGraphic: "/vorlagen/gmap_rodelbahn_c_s.png",
+ backgroundWidth: 23,
+ backgroundHeight: 23,
+ backgroundXOffset: -8,
+ backgroundYOffset: -8,
+ }
+ }),
+ new OpenLayers.Rule({
+ elseFilter: true,
+ symbolizer: {
+ externalGraphic: '/vorlagen/gmap${getSymbol}.png',
+ graphicWidth: 20,
+ graphicHeight: 34,
+ graphicXOffset: -10,
+ graphicYOffset: -33,
+ }
+ })
+ ]
+ }),
+ highlight: new OpenLayers.Style({
+ label: "${getTitle}",
+ labelOutlineColor: "white",
+ fontWeight: "bold"
}, {
context: {
getTitle: function(feature) {
if (feature.attributes.name !== undefined) title += feature.attributes.name;
return title;
}
- }
- }),
- 'highlight': new OpenLayers.Style({
- label: "${name}",
- labelOutlineColor: "white",
- labelYOffset: 12,
- fontWeight: "bold"
+ },
+ rules: [
+ new OpenLayers.Rule({
+ filter: filter_point_sledrun,
+ symbolizer: {
+ label: "${name}",
+ labelYOffset: 14
+ }
+ }),
+ new OpenLayers.Rule({
+ elseFilter: true,
+ symbolizer: {
+ labelYOffset: 40
+ }
+ })
+ ]
})
}),
rendererOptions: {yOrdering: true}