Now map features are highlighted when the mouse moves over them.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Thu, 14 Nov 2013 21:27:12 +0000 (21:27 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Thu, 14 Nov 2013 21:27:12 +0000 (21:27 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrmap/trunk@1803 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrmap.js

index b6aa15fa286477515576c0942f47ed9b6e8ab9fb..aeaf86d09f24894a983fc410fae7461b635a91f8 100644 (file)
--- 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}