Skip to content

Commit 86875e2

Browse files
committed
Add scale bar and improve OL styling
1 parent 2e1480f commit 86875e2

1 file changed

Lines changed: 26 additions & 22 deletions

File tree

src/components/MapComponent.vue

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { ref, onMounted } from 'vue'
33
import { Map, View } from 'ol'
4+
import { ScaleLine } from 'ol/control'
45
import DataCabinet from './DataCabinet.vue'
56
import GlobalFeedbackWidget from './GlobalFeedbackWidget.vue'
67
import ProcessingResults from './ProcessingResults.vue'
@@ -88,6 +89,8 @@ onMounted(async () => {
8889
updateLayers()
8990
9091
addMapClickHandler(map.value as Map, areaValues.value)
92+
// Add scale bar
93+
map.value.addControl(new ScaleLine())
9194
// Setup permalink functionality
9295
setupPermalink(map)
9396
}
@@ -224,6 +227,17 @@ defineExpose({
224227
overflow-y: auto;
225228
}
226229
230+
:deep(.ol-zoom),
231+
:deep(.ol-attribution),
232+
:deep(.ol-scale-line) {
233+
--ol-background-color: black;
234+
--ol-accent-background-color: #333333;
235+
--ol-subtle-background-color: rgba(128, 128, 128, 0.25);
236+
--ol-partial-background-color: rgba(0, 0, 0, 0.75);
237+
--ol-foreground-color: #eeeeee;
238+
--ol-subtle-foreground-color: #aaaaaa;
239+
}
240+
227241
:deep(.ol-zoom) {
228242
top: unset;
229243
right: unset;
@@ -232,41 +246,31 @@ defineExpose({
232246
z-index: 10000;
233247
}
234248
235-
:deep(.ol-attribution) {
249+
:deep(.ol-scale-line) {
236250
top: unset;
237251
right: unset;
238252
bottom: 1rem;
239-
left: calc(2rem + 10px);
253+
left: 3rem;
254+
z-index: 2000;
255+
}
256+
257+
:deep(.ol-attribution) {
258+
top: unset;
259+
right: unset;
260+
bottom: calc(4rem);
261+
left: 1rem;
240262
z-index: 10000;
241263
flex-direction: row;
242-
max-width: 90vw;
264+
max-width: 30vw;
243265
align-items: end;
266+
text-align: left;
244267
}
245268
246269
:deep(.ol-attribution button) {
247270
order: -1;
248271
}
249272
250-
:deep(.ol-zoom button),
251-
:deep(.ol-attribution button) {
252-
background-color: rgba(0, 0, 0, 0.8);
253-
color: #fff;
254-
}
255-
256-
:deep(.ol-zoom button:hover),
257-
:deep(.ol-attribution button:hover) {
258-
background-color: rgba(0, 0, 0, 1);
259-
color: #fff;
260-
}
261-
262273
:deep(.ol-attribution ul) {
263-
color: #000;
264274
font-size: 0.875rem;
265-
text-shadow: none;
266-
}
267-
268-
:deep(.ol-attribution ul li a) {
269-
color: #000;
270-
text-decoration: underline;
271275
}
272276
</style>

0 commit comments

Comments
 (0)