Highlight selected items.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Sun, 3 Jan 2021 18:03:16 +0000 (19:03 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Sun, 3 Jan 2021 18:03:16 +0000 (19:03 +0100)
wrmap.js

index b41c6ef476f68c72a19c741a1c93b48dab1890d2..1c11f50ad49e7a5a2727ad13647490e227a5940e 100644 (file)
--- a/wrmap.js
+++ b/wrmap.js
@@ -80,51 +80,71 @@ function init_wrmap(i, jq_map) {
                return condition;
        }
 
-       function style_point_function(feature, resolution) {
-               if (feature.get('type') == 'sledrun') {
+       function sledrun_icon_style(condition, highlight) {
+               let hl = highlight ? 'h' : 'n';
+               let src = img_path + '/marker_c_sledrun_' + condition + 'n' + hl + '.png';
+               return new ol.style.Style({
+                       image: new ol.style.Icon({
+                               src: src,
+                               imgSize: [17, 17],
+                               anchor: [0.5, 0.5]
+                       }),
+               });
+
+       }
+
+       function sledrun_icon_shadow_style() {
+               return new ol.style.Style({
+                       image: new ol.style.Icon({
+                               src: img_path + '/marker_c_shadow.png',
+                               imgSize: [23, 23],
+                               anchor: [0.4, 0.4]
+                       }),
+               });
+       }
+
+       function marker_icon_style(feature) {
+               let src = img_path + '/marker_p_' + feature.get('type') + '.png';
+               return new ol.style.Style({
+                       image: new ol.style.Icon({
+                               src: src,
+                               imgSize: [20, 34],
+                               anchor: [0.5, 1.0]
+                       }),
+               });
+       }
+
+       function point_style(feature, highlight) {
+               let sledrun = feature.get('type') == 'sledrun';
+               let icon_style;
+               if (sledrun) {
                        let condition = get_sledrun_condition(feature);
-                       let src = img_path + '/marker_c_sledrun_' + condition + 'nn.png';
-                       let marker_style = new ol.style.Style({
-                               image: new ol.style.Icon({
-                                       src: src,
-                                       imgSize: [17, 17],
-                                       anchor: [0.5, 0.5]
-                               }),
-                       });
-                       let shadow_style = new ol.style.Style({
-                               image: new ol.style.Icon({
-                                       src: img_path + '/marker_c_shadow.png',
-                                       imgSize: [23, 23],
-                                       anchor: [0.4, 0.4]
-                               }),
-                       });
-                       return [shadow_style, marker_style];
-
-               } else {
-                       let src = img_path + '/marker_p_' + feature.get('type') + '.png';
-                       let marker_style = new ol.style.Style({
-                               image: new ol.style.Icon({
-                                       src: src,
-                                       imgSize: [20, 34],
-                                       anchor: [0.5, 1.0]
+                       icon_style = sledrun_icon_style(condition, highlight);
+               } else icon_style = marker_icon_style(feature);
+               if (highlight) {
+                       icon_style.setText(new ol.style.Text({
+                               text: get_feature_title(feature),
+                               font: 'icon',
+                               offsetY: 14,
+                               stroke: new ol.style.Stroke({
+                                       color: '#ddd',
+                                       width: 2,
                                }),
-                       });
-                       return [marker_style];
+                       }));
                }
+               if (sledrun) {
+                       let shadow_style = sledrun_icon_shadow_style();
+                       return [shadow_style, icon_style];
+               }
+               return [icon_style];
+       }
+
+       function style_point_function(feature, resolution) {
+               return point_style(feature, false);
        }
 
        function style_point_function_highlight(feature, resolution) {
-               let style_array = style_point_function(feature, resolution);
-               style_array[0].setText(new ol.style.Text({
-                       text: get_feature_title(feature),
-                       font: 'icon',
-                       offsetY: 14,
-                       stroke: new ol.style.Stroke({
-                               color: '#ddd',
-                               width: 2,
-                       }),
-               }));
-               return style_array;
+               return point_style(feature, true);
        }
 
        function style_path_function(feature, resolution) {