annotate client/src/store/map.js @ 1296:99c039e86624

replaced manual store cleanup on logout with central store reset The store files now provide a init method with which the store can be resetted on logout. This is reasonable because missing store cleanups on logout caused bugs. Furthermore the localStorage.clear() was replaced specific removal of values since currently there are also saved cross profiles which should be persistent. The initialization of the cut/line/polygon tool was moved from their respective buttons to the map store right after saving the ol map object in the store. Before that change the map object was not present sometimes when trying to initiate those tools.
author Markus Kottlaender <markus@intevation.de>
date Thu, 22 Nov 2018 17:00:26 +0100
parents bc55ffaeb639
children e4e35fb2d995
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
1 /*
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
2 * This is Free Software under GNU Affero General Public License v >= 3.0
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
3 * without warranty, see README.md and license for details.
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
4 *
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
5 * SPDX-License-Identifier: AGPL-3.0-or-later
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
6 * License-Filename: LICENSES/AGPL-3.0.txt
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
7 *
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
8 * Copyright (C) 2018 by via donau
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
9 * – Österreichische Wasserstraßen-Gesellschaft mbH
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
10 * Software engineering by Intevation GmbH
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
11 *
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
12 * Author(s):
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
13 * Thomas Junk <thomas.junk@intevation.de>
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
14 */
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
15
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
16 //import { HTTP } from "../lib/http";
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
17
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
18 import TileWMS from "ol/source/TileWMS.js";
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
19 import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer.js";
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
20 import OSM from "ol/source/OSM";
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
21 import Draw from "ol/interaction/Draw.js";
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
22 import { Icon, Stroke, Style, Fill, Text, Circle } from "ol/style.js";
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
23 import VectorSource from "ol/source/Vector.js";
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
24 import Point from "ol/geom/Point.js";
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
25 import { bbox as bboxStrategy } from "ol/loadingstrategy";
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents: 1247
diff changeset
26 import { HTTP } from "../lib/http";
1158
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
27 import { fromLonLat } from "ol/proj";
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
28 import { getLength, getArea } from "ol/sphere.js";
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
29
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
30 // initial state
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
31 const init = () => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
32 return {
783
ab9604a46075 client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents: 782
diff changeset
33 openLayersMap: null,
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
34 identifiedFeatures: [], // map features identified by clicking on the map
1247
c14353e2cdb9 repositioning of buttons (issue225)
Markus Kottlaender <markus@intevation.de>
parents: 1237
diff changeset
35 currentMeasurement: null, // distance or area from line-/polygon-/cutTool
1237
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
36 lineTool: null, // open layers interaction object (Draw)
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
37 polygonTool: null, // open layers interaction object (Draw)
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
38 cutTool: null, // open layers interaction object (Draw)
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
39 layers: [
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
40 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
41 name: "Open Streetmap",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
42 data: new TileLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
43 source: new OSM()
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
44 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
45 isVisible: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
46 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
47 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
48 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
49 name: "Inland ECDIS chart Danube",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
50 data: new TileLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
51 source: new TileWMS({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
52 preload: 1,
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
53 url: "https://demo.d4d-portal.info/wms",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
54 params: { LAYERS: "d4d", VERSION: "1.1.1", TILED: true }
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
55 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
56 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
57 isVisible: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
58 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
59 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
60 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
61 name: "Fairway Dimensions",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
62 data: new VectorLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
63 source: new VectorSource(),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
64 style: function(feature) {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
65 return [
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
66 new Style({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
67 stroke: new Stroke({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
68 color: "rgba(0, 0, 255, 1.0)",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
69 width: 2
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
70 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
71 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
72 new Style({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
73 text: new Text({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
74 font: 'bold 12px "Open Sans", "sans-serif"',
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
75 placement: "line",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
76 fill: new Fill({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
77 color: "black"
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
78 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
79 text: "LOS: " + feature.get("level_of_service").toString()
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
80 //, zIndex: 10
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
81 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
82 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
83 ];
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
84 }
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
85 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
86 isVisible: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
87 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
88 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
89 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
90 name: "Waterway Area, named",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
91 data: new VectorLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
92 source: new VectorSource({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
93 strategy: bboxStrategy
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
94 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
95 style: new Style({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
96 stroke: new Stroke({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
97 color: "rgba(0, 132, 0, 1)",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
98 width: 2
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
99 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
100 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
101 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
102 isVisible: false,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
103 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
104 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
105 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
106 name: "Waterway Area",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
107 data: new VectorLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
108 source: new VectorSource({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
109 strategy: bboxStrategy
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
110 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
111 style: new Style({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
112 stroke: new Stroke({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
113 color: "rgba(0, 102, 0, 1)",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
114 width: 2
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
115 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
116 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
117 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
118 isVisible: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
119 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
120 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
121 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
122 name: "Waterway Axis",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
123 data: new VectorLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
124 source: new VectorSource({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
125 strategy: bboxStrategy
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
126 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
127 style: new Style({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
128 stroke: new Stroke({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
129 color: "rgba(0, 0, 255, .5)",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
130 lineDash: [5, 5],
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
131 width: 2
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
132 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
133 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
134 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
135 isVisible: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
136 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
137 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
138 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
139 name: "Distance marks",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
140 forLegendStyle: { point: true, resolution: 8 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
141 data: new VectorLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
142 source: new VectorSource({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
143 strategy: bboxStrategy
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
144 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
145 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
146 isVisible: false,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
147 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
148 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
149 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
150 name: "Bottlenecks",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
151 data: new VectorLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
152 source: new VectorSource({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
153 strategy: bboxStrategy
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
154 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
155 style: new Style({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
156 stroke: new Stroke({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
157 color: "rgba(230, 230, 10, .8)",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
158 width: 4
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
159 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
160 fill: new Fill({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
161 color: "rgba(230, 230, 10, .3)"
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
162 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
163 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
164 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
165 isVisible: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
166 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
167 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
168 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
169 name: "Bottleneck isolines",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
170 data: new TileLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
171 source: new TileWMS({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
172 preload: 0,
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
173 projection: "EPSG:3857",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
174 url: window.location.origin + "/api/internal/wms",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
175 params: {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
176 LAYERS: "sounding_results_contour_lines_geoserver",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
177 VERSION: "1.1.1",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
178 TILED: true
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
179 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
180 tileLoadFunction: function(tile, src) {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
181 // console.log("calling for", tile, src);
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
182 HTTP.get(src, {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
183 headers: {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
184 "X-Gemma-Auth": localStorage.getItem("token")
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
185 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
186 responseType: "blob"
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
187 }).then(response => {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
188 tile.getImage().src = URL.createObjectURL(response.data);
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
189 });
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
190 } // TODO tile.setState(TileState.ERROR);
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
191 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
192 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
193 isVisible: false,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
194 showInLegend: true
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
195 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
196 {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
197 name: "Distance marks, Axis",
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
198 forLegendStyle: { point: true, resolution: 8 },
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
199 data: new VectorLayer({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
200 source: new VectorSource({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
201 strategy: bboxStrategy
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
202 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
203 style: function(feature, resolution) {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
204 if (resolution < 10) {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
205 var s = new Style({
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
206 image: new Circle({
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
207 radius: 5,
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
208 fill: new Fill({ color: "rgba(255, 0, 0, 0.1)" }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
209 stroke: new Stroke({ color: "blue", width: 1 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
210 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
211 });
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
212 if (resolution < 6) {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
213 s.setText(
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
214 new Text({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
215 offsetY: 12,
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
216 font: '10px "Open Sans", "sans-serif"',
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
217 fill: new Fill({
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
218 color: "black"
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
219 }),
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
220 text: (feature.get("hectometre") / 10).toString()
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
221 })
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
222 );
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
223 }
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
224 return s;
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
225 } else {
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
226 return [];
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
227 }
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
228 }
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
229 }),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
230 isVisible: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
231 showInLegend: true
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
232 },
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
233 {
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
234 name: "Draw Tool",
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
235 data: new VectorLayer({
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
236 source: new VectorSource({ wrapX: false }),
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
237 style: function(feature) {
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
238 // adapted from OpenLayer's LineString Arrow Example
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
239 var geometry = feature.getGeometry();
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
240 var styles = [
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
241 // linestring
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
242 new Style({
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
243 stroke: new Stroke({
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
244 color: "#369aca",
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
245 width: 2
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
246 })
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
247 })
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
248 ];
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
249
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
250 if (geometry.getType() === "LineString") {
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
251 geometry.forEachSegment(function(start, end) {
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
252 var dx = end[0] - start[0];
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
253 var dy = end[1] - start[1];
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
254 var rotation = Math.atan2(dy, dx);
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
255 // arrows
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
256 styles.push(
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
257 new Style({
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
258 geometry: new Point(end),
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
259 image: new Icon({
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
260 // we need to make sure the image is loaded by Vue Loader
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents: 1247
diff changeset
261 src: require("../assets/linestring_arrow.png"),
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
262 // fiddling with the anchor's y value does not help to
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
263 // position the image more centered on the line ending, as the
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
264 // default line style seems to be slightly uncentered in the
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
265 // anti-aliasing, but the image is not placed with subpixel
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
266 // precision
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
267 anchor: [0.75, 0.5],
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
268 rotateWithView: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
269 rotation: -rotation
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
270 })
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
271 })
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
272 );
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
273 });
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
274 }
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
275 return styles;
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
276 }
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
277 }),
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
278 isVisible: true,
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
279 showInLegend: false
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
280 },
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
281 {
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
282 name: "Cut Tool",
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
283 data: new VectorLayer({
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
284 source: new VectorSource({ wrapX: false }),
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
285 style: function(feature) {
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
286 // adapted from OpenLayer's LineString Arrow Example
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
287 var geometry = feature.getGeometry();
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
288 var styles = [
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
289 // linestring
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
290 new Style({
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
291 stroke: new Stroke({
1197
49740dcba52c changed cut tool style
Markus Kottlaender <markus@intevation.de>
parents: 1158
diff changeset
292 color: "#333333",
49740dcba52c changed cut tool style
Markus Kottlaender <markus@intevation.de>
parents: 1158
diff changeset
293 width: 2,
49740dcba52c changed cut tool style
Markus Kottlaender <markus@intevation.de>
parents: 1158
diff changeset
294 lineDash: [7, 7]
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
295 })
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
296 })
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
297 ];
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
298
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
299 if (geometry.getType() === "LineString") {
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
300 geometry.forEachSegment(function(start, end) {
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
301 var dx = end[0] - start[0];
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
302 var dy = end[1] - start[1];
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
303 var rotation = Math.atan2(dy, dx);
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
304 // arrows
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
305 styles.push(
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
306 new Style({
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
307 geometry: new Point(end),
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
308 image: new Icon({
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
309 // we need to make sure the image is loaded by Vue Loader
1272
bc55ffaeb639 cleaned up client/src directory
Markus Kottlaender <markus@intevation.de>
parents: 1247
diff changeset
310 src: require("../assets/linestring_arrow_grey.png"),
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
311 // fiddling with the anchor's y value does not help to
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
312 // position the image more centered on the line ending, as the
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
313 // default line style seems to be slightly uncentered in the
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
314 // anti-aliasing, but the image is not placed with subpixel
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
315 // precision
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
316 anchor: [0.75, 0.5],
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
317 rotateWithView: true,
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
318 rotation: -rotation
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
319 })
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
320 })
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
321 );
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
322 });
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
323 }
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
324 return styles;
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
325 }
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
326 }),
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
327 isVisible: true,
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
328 showInLegend: false
1099
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
329 }
1f4799bab8a6 deleted layers/layers.js and moved content to map store
Markus Kottlaender <markus@intevation.de>
parents: 1096
diff changeset
330 ]
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
331 };
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
332 };
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
333
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
334 export default {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
335 init,
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
336 namespaced: true,
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
337 state: init(),
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
338 getters: {
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
339 layersForLegend: state => {
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
340 return state.layers.filter(layer => layer.showInLegend);
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
341 },
754
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 747
diff changeset
342 getLayerByName: state => name => {
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 747
diff changeset
343 return state.layers.find(layer => layer.name === name);
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
344 },
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
345 getVSourceByName: (state, getters) => name => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
346 return getters.getLayerByName(name).data.getSource();
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
347 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
348 },
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
349 mutations: {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
350 toggleVisibility: (state, layer) => {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
351 state.layers[layer].isVisible = !state.layers[layer].isVisible;
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
352 state.layers[layer].data.setVisible(state.layers[layer].isVisible);
770
c12ec7fde3f2 client: add simple identify top area box
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
353 },
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
354 openLayersMap: (state, map) => {
783
ab9604a46075 client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents: 782
diff changeset
355 state.openLayersMap = map;
1112
2c3d32322126 moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents: 1099
diff changeset
356 },
2c3d32322126 moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents: 1099
diff changeset
357 setIdentifiedFeatures: (state, identifiedFeatures) => {
2c3d32322126 moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents: 1099
diff changeset
358 state.identifiedFeatures = identifiedFeatures;
2c3d32322126 moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents: 1099
diff changeset
359 },
2c3d32322126 moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents: 1099
diff changeset
360 setCurrentMeasurement: (state, measurement) => {
2c3d32322126 moved identifystore properties to mapstore
Markus Kottlaender <markus@intevation.de>
parents: 1099
diff changeset
361 state.currentMeasurement = measurement;
1115
1b160eda22cf moved drawMode to map store
Markus Kottlaender <markus@intevation.de>
parents: 1114
diff changeset
362 },
1237
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
363 lineTool: (state, lineTool) => {
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
364 state.lineTool = lineTool;
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
365 },
1237
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
366 polygonTool: (state, polygonTool) => {
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
367 state.polygonTool = polygonTool;
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
368 },
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
369 cutTool: (state, cutTool) => {
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1122
diff changeset
370 state.cutTool = cutTool;
1158
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
371 },
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
372 moveMap: (state, { coordinates, zoom, preventZoomOut }) => {
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
373 let view = state.openLayersMap.getView();
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
374 const currentZoom = view.getZoom();
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
375 view.animate({
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
376 zoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom,
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
377 center: fromLonLat(coordinates, view.getProjection()),
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
378 duration: 700
da75faa8043f added central moveMap method to pan and zoom the map on certain events
Markus Kottlaender <markus@intevation.de>
parents: 1144
diff changeset
379 });
1144
5f98d0c9d738 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1140
diff changeset
380 }
1296
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
381 },
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
382 actions: {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
383 openLayersMap({ commit, dispatch, getters }, map) {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
384 const drawVectorSrc = getters.getVSourceByName("Draw Tool");
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
385 const cutVectorSrc = getters.getVSourceByName("Cut Tool");
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
386
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
387 // init line tool
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
388 const lineTool = new Draw({
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
389 source: drawVectorSrc,
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
390 type: "LineString",
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
391 maxPoints: 2
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
392 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
393 lineTool.setActive(false);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
394 lineTool.on("drawstart", () => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
395 drawVectorSrc.clear();
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
396 commit("setCurrentMeasurement", null);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
397 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
398 lineTool.on("drawend", event => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
399 commit("setCurrentMeasurement", {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
400 quantity: "Length",
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
401 unitSymbol: "m",
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
402 value: Math.round(getLength(event.feature.getGeometry()) * 10) / 10
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
403 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
404 commit("application/showIdentify", true, { root: true });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
405 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
406
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
407 // init polygon tool
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
408 const polygonTool = new Draw({
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
409 source: drawVectorSrc,
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
410 type: "Polygon",
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
411 maxPoints: 50
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
412 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
413 polygonTool.setActive(false);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
414 polygonTool.on("drawstart", () => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
415 drawVectorSrc.clear();
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
416 commit("setCurrentMeasurement", null);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
417 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
418 polygonTool.on("drawend", event => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
419 const areaSize = getArea(event.feature.getGeometry());
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
420 commit("setCurrentMeasurement", {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
421 quantity: "Area",
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
422 unitSymbol: areaSize > 100000 ? "km²" : "m²",
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
423 value:
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
424 areaSize > 100000
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
425 ? Math.round(areaSize / 1000) / 1000 // convert into 1 km² == 1000*1000 m² and round to 1000 m²
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
426 : Math.round(areaSize)
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
427 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
428 commit("application/showIdentify", true, { root: true });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
429 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
430
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
431 // init cut tool
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
432 const cutTool = new Draw({
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
433 source: cutVectorSrc,
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
434 type: "LineString",
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
435 maxPoints: 2,
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
436 style: new Style({
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
437 stroke: new Stroke({
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
438 color: "#444",
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
439 width: 2,
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
440 lineDash: [7, 7]
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
441 }),
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
442 image: new Circle({
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
443 fill: new Fill({ color: "#333" }),
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
444 stroke: new Stroke({ color: "#fff", width: 1.5 }),
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
445 radius: 6
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
446 })
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
447 })
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
448 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
449 cutTool.setActive(false);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
450 cutTool.on("drawstart", () => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
451 cutVectorSrc.clear();
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
452 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
453 cutTool.on("drawend", event => {
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
454 dispatch("fairwayprofile/cut", event.feature, { root: true });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
455 });
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
456
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
457 map.addInteraction(lineTool);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
458 map.addInteraction(cutTool);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
459 map.addInteraction(polygonTool);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
460
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
461 commit("lineTool", lineTool);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
462 commit("polygonTool", polygonTool);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
463 commit("cutTool", cutTool);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
464 commit("openLayersMap", map);
99c039e86624 replaced manual store cleanup on logout with central store reset
Markus Kottlaender <markus@intevation.de>
parents: 1272
diff changeset
465 }
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
466 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
467 };