Mercurial > gemma
annotate client/src/map/store.js @ 1063:7ec2133c6404
client: add area measurement. simpify code
* Add a third draw mode which can only be activated when no
morphology is selected and we are already in LineString mode.
It adds an area calculation. Because the Polygon drawMode ends
on a double click, there needs to be an extra callback for this to
run identify so that the area calculation is shown all times.
* Add Bernhard as author to some files and also simplify copyright
note.
* Remove DRAWMODES in the code to simplify as this is just one
indirection used once in stores/application.js.
* Use mapState instead mapGetters to get the drawMode at all places
to save some code lines.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Thu, 25 Oct 2018 23:16:53 +0200 |
parents | ca628dce90dd |
children |
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 |
967
2025074ad835
refac: extracted layer configuration to layers
Thomas Junk <thomas.junk@intevation.de>
parents:
939
diff
changeset
|
18 import { layers } from "../layers/layers"; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
19 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
20 const MapStore = { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
21 namespaced: true, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
22 state: { |
783
ab9604a46075
client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents:
782
diff
changeset
|
23 openLayersMap: null, |
975
3da707172772
refac: removed technical debt
Thomas Junk <thomas.junk@intevation.de>
parents:
967
diff
changeset
|
24 layers: layers |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
25 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
26 getters: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
27 layers: state => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
28 return state.layers; |
754
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
747
diff
changeset
|
29 }, |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
747
diff
changeset
|
30 getLayerByName: state => name => { |
105c421f99b1
refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents:
747
diff
changeset
|
31 return state.layers.find(layer => layer.name === name); |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
32 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
33 }, |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
34 mutations: { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
35 toggleVisibility: (state, layer) => { |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
36 state.layers[layer].isVisible = !state.layers[layer].isVisible; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
37 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
|
38 }, |
783
ab9604a46075
client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents:
782
diff
changeset
|
39 setOpenLayersMap: (state, map) => { |
ab9604a46075
client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents:
782
diff
changeset
|
40 state.openLayersMap = map; |
585
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
41 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
42 } |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
43 }; |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
44 |
ef307bd6b5d8
refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff
changeset
|
45 export default MapStore; |