Mercurial > gemma
annotate client/src/components/identify/Identify.vue @ 2747:fb5deecb77f1
client:identified box: implement the bbox zoom button
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Wed, 20 Mar 2019 17:19:59 +0100 |
parents | 4063adda3095 |
children | d0f6c222f4f9 |
rev | line source |
---|---|
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
1 <template> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
2 <div |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
3 :class="[ |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
4 'box ui-element rounded bg-white text-nowrap', |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
5 { expanded: showIdentify } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
6 ]" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
7 > |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
8 <div style="width: 18rem"> |
2387
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2372
diff
changeset
|
9 <UIBoxHeader icon="info" title="Identified" :closeCallback="close" /> |
2534
bb5286acfee2
client: reduced spacings between and inside boxes and more compact main menu
Markus Kottlaender <markus@intevation.de>
parents:
2441
diff
changeset
|
10 <div class="features"> |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
11 <div v-if="currentMeasurement"> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
12 <small class="d-block bg-dark text-light text-center px-2 py-1"> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
13 {{ $gettext("Measurement") }} |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
14 </small> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
15 <small class="d-flex justify-content-between px-2"> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
16 <b> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
17 {{ currentMeasurement.quantity }} |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
18 </b> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
19 {{ currentMeasurement.value }} {{ currentMeasurement.unitSymbol }} |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
20 </small> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
21 </div> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
22 <div |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
23 v-for="feature of filteredIdentifiedFeatures" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
24 :key="feature.getId()" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
25 > |
2743
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
26 <small |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
27 class="d-flex justify-content-between bg-dark text-light px-2 py-1" |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
28 > |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
29 {{ $gettext(featureLabel(feature)) }} |
2743
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
30 <a |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
31 v-if="feature.getProperties().hasOwnProperty('bbox')" |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
32 @click="zoomTo(feature)" |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
33 class="btn btn-info btn-xs pointer rounded-0 zoom-btn" |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
34 > |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
35 <font-awesome-icon icon="crosshairs" /> |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
36 </a> |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
37 </small> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
38 <small |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
39 v-for="prop in featureProps(feature)" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
40 :key="prop.key" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
41 v-if="prop.val" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
42 class="d-flex justify-content-between px-2" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
43 > |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
44 <b>{{ $gettext(prop.key) }}</b> |
2743
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
45 <span>{{ prop.val }}</span> |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
46 </small> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
47 </div> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
48 <div |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
49 v-if="!currentMeasurement && !filteredIdentifiedFeatures.length" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
50 class="text-muted small text-center my-auto py-3 px-2" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
51 > |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
52 <translate>No features identified.</translate> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
53 </div> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
54 </div> |
2534
bb5286acfee2
client: reduced spacings between and inside boxes and more compact main menu
Markus Kottlaender <markus@intevation.de>
parents:
2441
diff
changeset
|
55 <div class="versioninfo border-top box-body"> |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
56 <span v-translate="{ license: 'AGPL-3.0-or-later' }"> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
57 This app uses <i>gemma</i>, which is Free Software under <br /> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
58 %{ license } without warranty, see docs for details. |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
59 </span> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
60 <br /> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
61 <a href="https://hg.intevation.de/gemma/file/tip"> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
62 <translate>source-code</translate> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
63 </a> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
64 {{ versionStr }} <br />© via donau. ⓔ Intevation. <br /> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
65 <span v-translate="{ name: 'OpenSteetMap' }" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
66 >Some data © |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
67 <a href="https://www.openstreetmap.org/copyright">%{ name }</a> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
68 contributors. |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
69 </span> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
70 <br /> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
71 <span v-translate="{ geoLicense: 'CC-BY-4.0' }"> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
72 Uses |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
73 <a href="https://download.geonames.org/export/dump/readme.txt" |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
74 >GeoNames</a |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
75 > |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
76 under %{ geoLicense }. |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
77 </span> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
78 <translate>Generated PDFs use font: </translate> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
79 <a href="http://libertine-fonts.org">LinBiolinum</a> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
80 </div> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
81 </div> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
82 </div> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
83 </template> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
84 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
85 <style lang="scss" scoped> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
86 .features { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
87 max-height: 19rem; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
88 overflow-y: auto; |
2372
20e4efa64320
client: improved row colors in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2371
diff
changeset
|
89 small { |
2743
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
90 .zoom-btn { |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
91 margin-top: -0.25rem; |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
92 margin-right: -0.5rem; |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
93 margin-bottom: -0.25rem; |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
94 svg { |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
95 vertical-align: middle; |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
96 } |
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
97 } |
2372
20e4efa64320
client: improved row colors in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2371
diff
changeset
|
98 &:nth-child(even) { |
20e4efa64320
client: improved row colors in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2371
diff
changeset
|
99 background: #f8f8f8; |
20e4efa64320
client: improved row colors in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2371
diff
changeset
|
100 } |
20e4efa64320
client: improved row colors in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2371
diff
changeset
|
101 &:hover { |
20e4efa64320
client: improved row colors in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2371
diff
changeset
|
102 background: #eeeeee; |
20e4efa64320
client: improved row colors in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2371
diff
changeset
|
103 } |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
104 } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
105 } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
106 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
107 .versioninfo { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
108 font-size: 60%; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
109 white-space: normal; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
110 } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
111 </style> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
112 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
113 <script> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
114 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
115 * without warranty, see README.md and license for details. |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
116 * |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
117 * SPDX-License-Identifier: AGPL-3.0-or-later |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
118 * License-Filename: LICENSES/AGPL-3.0.txt |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
119 * |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
120 * Copyright (C) 2018, 2019 by via donau |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
121 * – Österreichische Wasserstraßen-Gesellschaft mbH |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
122 * Software engineering by Intevation GmbH |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
123 * |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
124 * Author(s): |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
125 * Thomas Junk <thomas.junk@intevation.de> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
126 * Bernhard E. Reiter <bernhard.reiter@intevation.de> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
127 * Markus Kottländer <markus.kottlaender@intevation.de> |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
128 */ |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
129 import { mapState, mapGetters } from "vuex"; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
130 import { formatter } from "./formatter"; |
2747
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
131 import { getCenter } from "ol/extent"; |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
132 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
133 export default { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
134 name: "identify", |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
135 computed: { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
136 ...mapGetters("application", ["versionStr"]), |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
137 ...mapState("application", ["showIdentify"]), |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
138 ...mapGetters("map", ["filteredIdentifiedFeatures"]), |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
139 ...mapState("map", ["currentMeasurement"]) |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
140 }, |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
141 methods: { |
2743
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
142 zoomTo(feature) { |
2747
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
143 this.$store.commit("map/moveMap", { |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
144 coordinates: getCenter( |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
145 feature |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
146 .getGeometry() |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
147 .clone() |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
148 .transform("EPSG:3857", "EPSG:4326") |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
149 .getExtent() |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
150 ), |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
151 zoom: 17, |
fb5deecb77f1
client:identified box: implement the bbox zoom button
Fadi Abbud <fadi.abbud@intevation.de>
parents:
2743
diff
changeset
|
152 preventZoomOut: true |
2735
3c2ac140ad30
identify_tool: zoom to BBox PoC implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2534
diff
changeset
|
153 }); |
3c2ac140ad30
identify_tool: zoom to BBox PoC implemented
Thomas Junk <thomas.junk@intevation.de>
parents:
2534
diff
changeset
|
154 }, |
2387
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2372
diff
changeset
|
155 close() { |
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2372
diff
changeset
|
156 this.$store.commit("application/showIdentify", false); |
f185503ef35a
client: unified box's header styles by creating a reusable component
Markus Kottlaender <markus@intevation.de>
parents:
2372
diff
changeset
|
157 }, |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
158 featureId(feature) { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
159 // cut away everything from the last . to the end |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
160 return feature.getId().replace(/[.][^.]*$/, ""); |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
161 }, |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
162 featureLabel(feature) { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
163 if (formatter.hasOwnProperty(this.featureId(feature))) { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
164 return formatter[this.featureId(feature)].label; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
165 } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
166 return this.featureId(feature); |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
167 }, |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
168 featureProps(feature) { |
2441
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2424
diff
changeset
|
169 let featureId = this.featureId(feature); |
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2424
diff
changeset
|
170 |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
171 // create array with {key, val} objects |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
172 let propsArray = []; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
173 Object.keys(feature.getProperties()).forEach(key => { |
2423
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
174 // skip geometry (would lead to cyclic object error) |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
175 if (key !== feature.getGeometryName()) { |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
176 let val = feature.getProperties()[key]; |
2405
ef928c63388a
client: handle json values in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2387
diff
changeset
|
177 |
2423
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
178 // if val is a valid json object string, spread its values into the array |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
179 let jsonObj = this.getObjectFromString(val); |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
180 if (jsonObj) { |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
181 Object.keys(jsonObj).forEach(key => { |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
182 propsArray.push({ key, val: jsonObj[key] }); |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
183 }); |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
184 } else { |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
185 // otherwise just put the key value pair into the array |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
186 propsArray.push({ key, val }); |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
187 } |
2405
ef928c63388a
client: handle json values in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2387
diff
changeset
|
188 } |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
189 }); |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
190 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
191 // change labels and remove unneeded properties |
2441
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2424
diff
changeset
|
192 // for all features |
2743
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
193 propsArray = propsArray.map(formatter.all).filter(p => p); |
2441
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2424
diff
changeset
|
194 // feature specific |
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2424
diff
changeset
|
195 if ( |
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2424
diff
changeset
|
196 formatter.hasOwnProperty(featureId) && |
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2424
diff
changeset
|
197 formatter[featureId].hasOwnProperty("props") |
9de710bdb535
client: improved identify box formatter
Markus Kottlaender <markus@intevation.de>
parents:
2424
diff
changeset
|
198 ) { |
2743
4063adda3095
client: identified box: moved bbox zoom button to feature headers and removed bbox from the feature's properties list
Markus Kottlaender <markus@intevation.de>
parents:
2735
diff
changeset
|
199 propsArray = propsArray.map(formatter[featureId].props).filter(p => p); |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
200 } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
201 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
202 // remove underscores in labels that where not previously changed already |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
203 propsArray = propsArray.map(prop => { |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
204 return { key: prop.key.replace(/_/g, " "), val: prop.val }; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
205 }); |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
206 |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
207 return propsArray; |
2423
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
208 }, |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
209 getObjectFromString(val) { |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
210 // JSON.parse() accepts integers and null as valid json. So to be sure to |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
211 // get an object, we cannot just try JSON.parse() but we need to check if |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
212 // the given value is a string and starts with a {. |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
213 if ( |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
214 Object.prototype.toString.call(val) === "[object String]" && |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
215 val[0] === "{" |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
216 ) { |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
217 try { |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
218 return JSON.parse(val); |
2424
b6deb03ef13f
client: fix linter error (empty block)
Markus Kottlaender <markus@intevation.de>
parents:
2423
diff
changeset
|
219 } catch (e) { |
b6deb03ef13f
client: fix linter error (empty block)
Markus Kottlaender <markus@intevation.de>
parents:
2423
diff
changeset
|
220 return null; |
b6deb03ef13f
client: fix linter error (empty block)
Markus Kottlaender <markus@intevation.de>
parents:
2423
diff
changeset
|
221 } |
2423
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
222 } |
3423cd4b3136
client: fix json parsing in identify box
Markus Kottlaender <markus@intevation.de>
parents:
2405
diff
changeset
|
223 return null; |
2371
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
224 } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
225 } |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
226 }; |
045bac575294
client: fixed broken previous commit
Markus Kottlaender <markus@intevation.de>
parents:
diff
changeset
|
227 </script> |