Mercurial > gemma
annotate client/src/components/layers/LegendElement.vue @ 4273:9abb63b6b80a
Legend: make styles reloadable
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 28 Aug 2019 14:31:19 +0200 |
parents | dd8ec623b969 |
children | e4ff09ebc2c3 |
rev | line source |
---|---|
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 <template> |
4273
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
2 <div :id="id" class="legendelement"> |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
3 <img |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
4 v-if="!isVectorLayer" |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
5 style="margin: 0 auto;display: flex;" |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
6 :src="imgSrc" |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
7 :key="id" |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
8 /> |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
9 </div> |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
10 </template> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
11 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
12 <script> |
1362
ca33ad696594
remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1361
diff
changeset
|
13 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
14 * without warranty, see README.md and license for details. |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1272
diff
changeset
|
15 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
16 * SPDX-License-Identifier: AGPL-3.0-or-later |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
17 * License-Filename: LICENSES/AGPL-3.0.txt |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1272
diff
changeset
|
18 * |
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1272
diff
changeset
|
19 * Copyright (C) 2018 by via donau |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
20 * – Österreichische Wasserstraßen-Gesellschaft mbH |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
21 * Software engineering by Intevation GmbH |
1361
ea3a89a1813a
remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents:
1272
diff
changeset
|
22 * |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
23 * Author(s): |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
24 * Thomas Junk <thomas.junk@intevation.de> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
25 */ |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
26 import { mapState } from "vuex"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
27 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
28 import { Map, View } from "ol"; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
29 import Feature from "ol/Feature"; |
2985
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2957
diff
changeset
|
30 import { Vector as VectorLayer } from "ol/layer"; |
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2957
diff
changeset
|
31 import { Vector as VectorSource } from "ol/source"; |
1b8bb4f89227
client: removed .js and .vue extention from imports
Markus Kottlaender <markus@intevation.de>
parents:
2957
diff
changeset
|
32 import LineString from "ol/geom/LineString"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
33 import Point from "ol/geom/Point"; |
3029
81c2e561fe03
Use distance marks an axis via WMS. Added legend and featureinfo.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2985
diff
changeset
|
34 import { HTTP } from "@/lib/http"; |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
35 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
36 export default { |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
37 props: ["layer"], |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
38 data: function() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
39 return { |
4273
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
40 myMap: null, |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
41 src: null, |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
42 url: null |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
43 }; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
44 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
45 computed: { |
4272
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
46 ...mapState("map", ["layers", "ongoingRefresh"]), |
4273
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
47 isVectorLayer() { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
48 return this.layer.getType() === "VECTOR"; |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
49 }, |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
50 imgSrc() { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
51 if (this.layer.get("id") === "DISTANCEMARKSAXIS") { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
52 return require("@/assets/distancemarks-axis.png"); |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
53 } |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
54 return this.src; |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
55 }, |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
56 id() { |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
57 return ( |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
58 "legendelement-" + |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
59 this.layer |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
60 .get("label") |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
61 .toLowerCase() |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
62 .replace(/\s/g, "") |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
63 ); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
64 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
65 mstyle() { |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
66 if (this.layer && this.layer.getStyle) { |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
67 return this.layer.getStyle(); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
68 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
69 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
70 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
71 watch: { |
4272
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
72 ongoingRefresh() { |
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
73 if (this.ongoingRefresh) return; |
4273
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
74 if ( |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
75 this.layer.get("id") === "OPENSTREETMAP" || |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
76 this.layer.get("id") === "INLANDECDIS" || |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
77 this.layer.get("id") === "BOTTLENECKISOLINE" || |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
78 this.layer.get("id") === "DIFFERENCES" |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
79 ) { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
80 // TODO: Do something useful? |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
81 return; |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
82 } |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
83 if (this.isVectorLayer) { |
4272
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
84 this.recreateLayers(); |
4273
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
85 } else { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
86 this.loadImageSrc(); |
4272
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
87 } |
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
88 }, |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
89 mstyle(newStyle, oldStyle) { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
90 // only recreate if there already was a style before |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
91 if (oldStyle) { |
4272
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
92 this.recreateLayers(); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
93 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
94 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
95 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
96 mounted() { |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
97 if (this.layer.getType() == "VECTOR") { |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
98 this.initMap(); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
99 } else { |
3031 | 100 if ( |
101 this.layer.get("id") === "OPENSTREETMAP" || | |
3029
81c2e561fe03
Use distance marks an axis via WMS. Added legend and featureinfo.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2985
diff
changeset
|
102 this.layer.get("id") === "INLANDECDIS" || |
81c2e561fe03
Use distance marks an axis via WMS. Added legend and featureinfo.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2985
diff
changeset
|
103 this.layer.get("id") === "BOTTLENECKISOLINE" || |
81c2e561fe03
Use distance marks an axis via WMS. Added legend and featureinfo.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2985
diff
changeset
|
104 this.layer.get("id") === "DIFFERENCES" |
81c2e561fe03
Use distance marks an axis via WMS. Added legend and featureinfo.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2985
diff
changeset
|
105 ) { |
81c2e561fe03
Use distance marks an axis via WMS. Added legend and featureinfo.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2985
diff
changeset
|
106 // TODO: Do something useful? |
3031 | 107 return; |
3029
81c2e561fe03
Use distance marks an axis via WMS. Added legend and featureinfo.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
2985
diff
changeset
|
108 } |
4273
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
109 this.url = |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
110 `/internal/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=` + |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
111 this.layer.getSource().getParams().LAYERS + |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
112 `&legend_options=columns:4;fontAntiAliasing:true`; |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
113 this.loadImageSrc(); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
114 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
115 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
116 methods: { |
4273
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
117 loadImageSrc() { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
118 HTTP.get(this.url, { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
119 headers: { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
120 "X-Gemma-Auth": localStorage.getItem("token") |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
121 }, |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
122 responseType: "blob" |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
123 }).then(response => { |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
124 this.src = URL.createObjectURL(response.data); |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
125 }); |
9abb63b6b80a
Legend: make styles reloadable
Thomas Junk <thomas.junk@intevation.de>
parents:
4272
diff
changeset
|
126 }, |
4272
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
127 recreateLayers() { |
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
128 let vector = this.createVectorLayer(); |
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
129 |
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
130 this.myMap.removeLayer(this.myMap.getLayers()[0]); |
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
131 this.myMap.addLayer(vector); |
dd8ec623b969
LegendElement: refresh legend elements for vector layers
Thomas Junk <thomas.junk@intevation.de>
parents:
3048
diff
changeset
|
132 }, |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
133 initMap() { |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
134 let vector = this.createVectorLayer(); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
135 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
136 this.myMap = new Map({ |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
137 layers: [vector], |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
138 target: this.id, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
139 controls: [], |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
140 interactions: [], |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
141 view: new View({ |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
142 center: [0, 0], |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
143 zoom: 3, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
144 projection: "EPSG:4326" |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
145 }) |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
146 }); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
147 }, |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
148 createVectorLayer() { |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
149 let mapStyle = this.layer.getStyle(); |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
150 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
151 let feature = new Feature({ |
3048
b8b95292d45f
Updated Legend style for vector layers to fit geoserver WMS default
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3031
diff
changeset
|
152 geometry: new LineString([[-1, -1], [0, 0], [1, 1]]) |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
153 }); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
154 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
155 // special case if we need to call the style function with a special |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
156 // parameter or to detect a point layer |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
157 let legendStyle = this.layer.get("forLegendStyle"); |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
158 if (legendStyle) { |
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
159 if (legendStyle) { |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
160 feature.setGeometry(new Point([0, 0])); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
161 } |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
162 mapStyle = this.layer.getStyleFunction()( |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
163 feature, |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
164 legendStyle.resolution, |
2506
89c439721db2
client: new symbold for critical bottlenecks, normal bottlenecks are not marked anymore
Markus Kottlaender <markus@intevation.de>
parents:
1558
diff
changeset
|
165 true |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
166 ); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
167 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
168 |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
169 // we could add extra properties here, if they are needed for |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
170 // the styling function in the future. An idea is to extend the |
2957
b74ebeb2bdc8
client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents:
2952
diff
changeset
|
171 // this.layer["forLegendStyle"] for it. |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
172 // FIXME, this is a special case for the Fairway Dimensions style |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
173 feature.set("level_of_service", ""); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
174 return new VectorLayer({ |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
175 source: new VectorSource({ |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
176 features: [feature], |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
177 wrapX: false |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
178 }), |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
179 style: mapStyle |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
180 }); |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
181 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
182 } |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
183 }; |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
184 </script> |
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
185 |
1449 | 186 <style lang="scss" scoped> |
187 .legendelement { | |
188 max-height: 1.5rem; | |
189 width: 2rem; | |
190 } | |
1272
bc55ffaeb639
cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
191 </style> |