annotate client/src/components/layers/Layerselect.vue @ 4580:02cf2b4be955 iso-areas

Use new areas layer in client.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 08 Oct 2019 13:08:55 +0200
parents 4f81082899c8
children db4e7fecad0d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
1 <template>
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
2 <div
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
3 class="d-flex flex-column flex-start px-2 border-bottom"
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
4 style="border-bottom-style: dashed !important;"
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
5 >
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
6 <div class="d-flex">
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1277
diff changeset
7 <input
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
8 v-for="map in openLayersMaps"
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
9 :key="map.getTarget()"
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
10 class="mt-1 mr-1"
2957
b74ebeb2bdc8 client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents: 2953
diff changeset
11 type="checkbox"
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
12 @change="toggle(map)"
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
13 :checked="isVisible(map)"
1480
9b81ac91a43e fix: linting
Thomas Junk <thomas.junk@intevation.de>
parents: 1449
diff changeset
14 />
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
15 <LegendElement class="pointer" :layer="layer" @click.native="toggle()" />
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
16 <label class="pointer layername form-check-label ml-1" @click="toggle()">
2957
b74ebeb2bdc8 client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents: 2953
diff changeset
17 {{ label }}
2952
a3017800e045 client: map legend: reduced code
Markus Kottlaender <markus@intevation.de>
parents: 2951
diff changeset
18 </label>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
19 </div>
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
20 <div>
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
21 <div v-if="isVisible() && layer.get('id') === 'BOTTLENECKISOLINE'">
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
22 <img class="rounded my-1 d-block" :src="isolinesLegendImgDataURL" />
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
23 </div>
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
24 <div v-if="isVisible() && layer.get('id') === 'DIFFERENCES'">
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
25 <img class="rounded my-1 d-block" :src="differencesLegendImgDataURL" />
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
26 </div>
2932
173ce013a021 layers: difference layer now contains legend
Thomas Junk <thomas.junk@intevation.de>
parents: 2920
diff changeset
27 </div>
1361
ea3a89a1813a remove trailing whitespace, add headers for Makefile, add the missed authors
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1277
diff changeset
28 </div>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
29 </template>
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
30
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
31 <script>
1362
ca33ad696594 remove the first empyty lines
Fadi Abbud <fadi.abbud@intevation.de>
parents: 1361
diff changeset
32 /* 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
33 * 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: 1277
diff changeset
34 *
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
35 * SPDX-License-Identifier: AGPL-3.0-or-later
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
36 * 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: 1277
diff changeset
37 *
1926
1220cfe96efd client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents: 1669
diff changeset
38 * Copyright (C) 2018, 2019 by via donau
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
39 * – Österreichische Wasserstraßen-Gesellschaft mbH
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
40 * 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: 1277
diff changeset
41 *
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
42 * Author(s):
1926
1220cfe96efd client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents: 1669
diff changeset
43 * * Thomas Junk <thomas.junk@intevation.de>
1220cfe96efd client: prepare isoline legend graphic for reuse
Bernhard Reiter <bernhard@intevation.de>
parents: 1669
diff changeset
44 * * Bernhard Reiter <bernhard.reiter@intevation.de>
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
45 */
1613
f2d24dceecc7 refac: cleanup import paths
Thomas Junk <thomas.junk@intevation.de>
parents: 1558
diff changeset
46 import { HTTP } from "@/lib/http";
2960
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
47 import { displayError } from "@/lib/errors";
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
48 import { mapState, mapGetters } from "vuex";
2920
c1f2b9148cc8 client: removed more unnecessary closing tags and opzimized imports
Markus Kottlaender <markus@intevation.de>
parents: 2851
diff changeset
49
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
50 export default {
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
51 components: {
2960
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
52 LegendElement: () => import("./LegendElement")
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
53 },
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
54 props: ["layerId"],
1927
5a37ee321651 client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents: 1926
diff changeset
55 computed: {
2932
173ce013a021 layers: difference layer now contains legend
Thomas Junk <thomas.junk@intevation.de>
parents: 2920
diff changeset
56 ...mapState("map", [
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
57 "openLayersMaps",
2932
173ce013a021 layers: difference layer now contains legend
Thomas Junk <thomas.junk@intevation.de>
parents: 2920
diff changeset
58 "isolinesLegendImgDataURL",
4275
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
59 "differencesLegendImgDataURL",
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
60 "ongoingRefresh"
2932
173ce013a021 layers: difference layer now contains legend
Thomas Junk <thomas.junk@intevation.de>
parents: 2920
diff changeset
61 ]),
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
62 ...mapGetters("map", ["openLayersMap"]),
4008
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
63 ...mapState("bottlenecks", ["selectedSurvey"]),
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
64 layer() {
3079
57255fda7594 client: compare surveys on map
Markus Kottlaender <markus@intevation.de>
parents: 3055
diff changeset
65 return this.openLayersMap().getLayer(this.layerId);
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
66 },
2957
b74ebeb2bdc8 client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents: 2953
diff changeset
67 label() {
b74ebeb2bdc8 client: layers: improved structure of layer configuration
Markus Kottlaender <markus@intevation.de>
parents: 2953
diff changeset
68 return this.$gettext(this.layer.get("label"));
2343
33d2ef9f9e5d client: use the name constants for Layer names
Fadi Abbud <fadi.abbud@intevation.de>
parents: 2154
diff changeset
69 }
1927
5a37ee321651 client: make isolines legend graphic internally availableo
Bernhard Reiter <bernhard@intevation.de>
parents: 1926
diff changeset
70 },
4275
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
71 watch: {
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
72 ongoingRefresh() {
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
73 if (this.ongoingRefresh) return;
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
74 this.refreshLegend();
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
75 }
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
76 },
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
77 methods: {
4275
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
78 refreshLegend() {
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
79 if (this.layer.get("id") === "BOTTLENECKISOLINE") {
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
80 this.loadLegendImage(
4580
02cf2b4be955 Use new areas layer in client.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 4275
diff changeset
81 "sounding_results_areas_geoserver",
4275
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
82 "isolinesLegendImgDataURL"
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
83 );
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
84 }
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
85 if (this.layer.get("id") === "DIFFERENCES") {
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
86 this.loadLegendImage(
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
87 "sounding_differences",
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
88 "differencesLegendImgDataURL"
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
89 );
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
90 }
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
91 },
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
92 toggle(map) {
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
93 if (map) {
4008
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
94 if (
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
95 (this.layerId === "BOTTLENECKISOLINE" ||
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
96 this.layerId === "DIFFERENCES") &&
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
97 !this.selectedSurvey
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
98 ) {
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
99 map
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
100 .getLayer(this.layerId)
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
101 .getSource()
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
102 .updateParams({
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
103 cql_filter: `bottleneck_id='NO_BOTTLENECK_SELECTED'`
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
104 });
224ee5a3acb1 Layerselect: when no bottleneck/no survey is selected, both ISOLINE and DIFFERENCES layer are activated with cql filter for bottleneck_id=NO_BOTTLENECK_SELECTED
Thomas Junk <thomas.junk@intevation.de>
parents: 3444
diff changeset
105 }
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
106 map
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
107 .getLayer(this.layerId)
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
108 .setVisible(!map.getLayer(this.layerId).getVisible());
3434
9fba1be118e7 client: data accuracy: Show diagrams for gauges, bottlenecks and stretches on map.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3079
diff changeset
109 if (
9fba1be118e7 client: data accuracy: Show diagrams for gauges, bottlenecks and stretches on map.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3079
diff changeset
110 this.layerId === "GAUGES" ||
9fba1be118e7 client: data accuracy: Show diagrams for gauges, bottlenecks and stretches on map.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3079
diff changeset
111 this.layerId === "STRETCHES" ||
3444
1559566662f5 client: data accuracy: Add diagram for sections.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3434
diff changeset
112 this.layerId === "BOTTLENECKS" ||
1559566662f5 client: data accuracy: Add diagram for sections.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3434
diff changeset
113 this.layerId === "SECTIONS"
3434
9fba1be118e7 client: data accuracy: Show diagrams for gauges, bottlenecks and stretches on map.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3079
diff changeset
114 ) {
9fba1be118e7 client: data accuracy: Show diagrams for gauges, bottlenecks and stretches on map.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3079
diff changeset
115 map.getLayer("DATAAVAILABILITY").changed();
9fba1be118e7 client: data accuracy: Show diagrams for gauges, bottlenecks and stretches on map.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 3079
diff changeset
116 }
3055
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
117 } else {
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
118 this.openLayersMaps.forEach(m => {
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
119 m.getLayer(this.layerId).setVisible(
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
120 !m.getLayer(this.layerId).getVisible()
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
121 );
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
122 });
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
123 }
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
124 },
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
125 isVisible(map) {
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
126 if (map) {
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
127 return map.getLayer(this.layerId).getVisible();
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
128 } else {
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
129 let isVisible = false;
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
130 this.openLayersMaps.forEach(m => {
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
131 if (m.getLayer(this.layerId).getVisible()) {
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
132 isVisible = true;
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
133 }
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
134 });
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
135 return isVisible;
b3c24c47931c client: layers legend: support multiple maps
Markus Kottlaender <markus@intevation.de>
parents: 3006
diff changeset
136 }
2960
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
137 },
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
138 loadLegendImage(layer, storeTarget) {
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
139 HTTP.get(
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
140 `/internal/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=${layer}&legend_options=columns:4;fontAntiAliasing:true`,
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
141 {
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
142 headers: {
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
143 Accept: "image/png",
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
144 "X-Gemma-Auth": localStorage.getItem("token")
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
145 },
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
146 responseType: "blob"
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
147 }
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
148 )
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
149 .then(response => {
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
150 const reader = new FileReader();
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
151 reader.onload = event => {
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
152 this.$store.commit("map/" + storeTarget, event.target.result);
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
153 };
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
154 reader.readAsDataURL(response.data);
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
155 })
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
156 .catch(error => {
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
157 displayError({
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
158 title: this.$gettext("Backend Error"),
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
159 message: `${error.response.status}: ${error.response.statusText}`
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
160 });
41cdff9b7f4a client: layer legend: removed unnecessary methods, added method for legend image loading and added error handling
Markus Kottlaender <markus@intevation.de>
parents: 2957
diff changeset
161 });
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
162 }
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
163 },
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents:
diff changeset
164 created() {
4275
4f81082899c8 Legend: legend for bottlnecks isoline and differences should reload as well
Thomas Junk <thomas.junk@intevation.de>
parents: 4008
diff changeset
165 this.refreshLegend();
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 </script>