From 152cc3e787873d890be2b673b506d441b2a32542 Mon Sep 17 00:00:00 2001 From: philipp Date: Thu, 14 Nov 2013 21:27:12 +0000 Subject: [PATCH] Now map features are highlighted when the mouse moves over them. git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrmap/trunk@1803 7aebc617-e5e2-0310-91dc-80fb5f6d2477 --- wrmap.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/wrmap.js b/wrmap.js index b6aa15f..aeaf86d 100644 --- a/wrmap.js +++ b/wrmap.js @@ -96,6 +96,13 @@ function init_wrmap(i, jq_map) { value: 'sledrun' }); + // Returns 0 to 5 for features that represent sledruns as their condition + var get_sledrun_condition = function(feature) { + if (feature.attributes.condition === undefined) return 0; + return feature.attributes.condition; + } + + var layer_point = new OpenLayers.Layer.Vector("Point", { styleMap: new OpenLayers.StyleMap({ 'default': new OpenLayers.Style({ @@ -105,10 +112,7 @@ function init_wrmap(i, jq_map) { 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.attributes.condition === undefined) return 0; - return feature.attributes.condition; - }, + getCondition: get_sledrun_condition, getSymbol: function(feature) { var name = feature.attributes.type; return name; @@ -118,7 +122,7 @@ function init_wrmap(i, jq_map) { new OpenLayers.Rule({ filter: filter_point_sledrun, symbolizer: { - externalGraphic: '/vorlagen/bahnzustand${getCondition}_0.png', + externalGraphic: '/vorlagen/bahnzustand${getCondition}nn.png', graphicWidth: 17, graphicHeight: 17, graphicXOffset: -8, @@ -148,6 +152,7 @@ function init_wrmap(i, jq_map) { fontWeight: "bold" }, { context: { + getCondition: get_sledrun_condition, getTitle: function(feature) { var title = ''; if (feature.attributes.type != 'point') { @@ -164,7 +169,8 @@ function init_wrmap(i, jq_map) { filter: filter_point_sledrun, symbolizer: { label: "${name}", - labelYOffset: 14 + labelYOffset: 14, + externalGraphic: '/vorlagen/bahnzustand${getCondition}nh.png' } }), new OpenLayers.Rule({ @@ -177,6 +183,18 @@ function init_wrmap(i, jq_map) { }), select: new OpenLayers.Style({ fillOpacity: 1. + }, { + context: { + getCondition: get_sledrun_condition, + }, + rules: [ + new OpenLayers.Rule({ + filter: filter_point_sledrun, + symbolizer: { + externalGraphic: '/vorlagen/bahnzustand${getCondition}nh.png' + } + }) + ] }) }), rendererOptions: {yOrdering: true} -- 2.30.2