Skip to content

Commit 1ebf4b0

Browse files
committed
refactor(ol-zone-control): pass through original Options and updated docs
1 parent e06b795 commit 1ebf4b0

File tree

6 files changed

+99
-31
lines changed

6 files changed

+99
-31
lines changed

docs/componentsguide/mapcontrols/zone/index.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,30 @@
22

33
> A control to jump from one zone to another.
44
5-
## Demo
5+
<script setup>
6+
import ZoneControlDemo from "@demos/ZoneControlDemo.vue"
7+
</script>
8+
<ClientOnly>
9+
<ZoneControlDemo />
10+
</ClientOnly>
611

7-
See [App Demo page for all Map Controls](../../../demo.md)
12+
## Usage
13+
14+
Add context menu to map
15+
16+
::: code-group
17+
18+
<<< ../../../../src/demos/ZoneControlDemo.vue
19+
20+
:::
821

922
## Properties
1023

1124
### className
1225

1326
- **Type**: `String`
1427

15-
### zone
28+
### zones
1629

1730
an array of zone: `{ name, extent (in EPSG:4326) }`
1831

src/assets/style.css

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
.ol-zoomslider {
1+
.ol-viewport .ol-zoomslider {
22
top: 7.5em;
33
left: 0.5em;
44
height: 240px;
55
border: 2px solid rgba(0, 60, 136, 0.5);
66
}
77

8-
.ol-overviewmap {
8+
.ol-viewport .ol-overviewmap {
99
left: 3.5em;
1010
bottom: 2.5em;
1111
}
1212

13-
.ol-mouse-position {
13+
.ol-viewport .ol-mouse-position {
1414
top: 0;
1515
left: 50%;
1616
transform: translate(-50%, 0);
@@ -19,31 +19,31 @@
1919
text-align: center;
2020
}
2121

22-
.ol-rotate {
22+
.ol-viewport .ol-rotate {
2323
top: 0.5em;
2424
right: 2.5em;
2525
transition: opacity 0.25s linear, visibility 0s linear;
2626
}
2727

28-
.ol-layerswitcher-image .ol-layer-hidden {
28+
.ol-viewport .ol-layerswitcher-image .ol-layer-hidden {
2929
opacity: 1;
3030
}
3131

32-
.ol-overviewmap.ol-collapsed .ol-overviewmap-map,
33-
.ol-overviewmap.ol-uncollapsible button {
32+
.ol-viewport .ol-overviewmap.ol-collapsed .ol-overviewmap-map,
33+
.ol-viewport .ol-overviewmap.ol-uncollapsible button {
3434
display: block;
3535
opacity: 0;
3636
}
3737

38-
.ol-collapsed {
38+
.ol-viewport .ol-collapsed {
3939
background-color: rgba(255, 255, 255, 0);
4040
}
4141

42-
.ol-collapsed:hover {
42+
.ol-viewport .ol-collapsed:hover {
4343
background-color: rgba(255, 255, 255, 0);
4444
}
4545

46-
.ol-layerswitcher-image button {
46+
.ol-viewport .ol-layerswitcher-image button {
4747
background-color: transparent;
4848
}
4949

src/components/layers/OlAnimatedClusterLayer.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const props = withDefaults(
3030
>(),
3131
{
3232
...layersCommonDefaultProps,
33-
className: "ol-layer",
3433
opacity: 1,
3534
visible: true,
3635
animationDuration: 700,

src/components/mapControls/OlZoneControl.vue

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,17 @@
22
<div v-if="false"></div>
33
</template>
44
<script setup lang="ts">
5-
import Zone from "ol-ext/control/MapZone";
5+
import MapZone, { type Options, type Zone } from "ol-ext/control/MapZone";
66
import { useAttrs } from "vue";
7-
import type { Layer } from "ol/layer";
87
import useControl from "@/composables/useControl";
98
import usePropsAsObjectProperties from "@/composables/usePropsAsObjectProperties";
10-
import type { ProjectionLike } from "ol/proj";
119
1210
const props = withDefaults(
13-
defineProps<{
14-
className?: string;
15-
zones?: Zone[];
16-
layer?: Layer | ((zone: Zone) => Layer);
17-
projection?: ProjectionLike;
18-
centerOnClick?: boolean;
19-
}>(),
11+
defineProps<
12+
Omit<Options, "className" | "zone"> & { className: string; zones: Zone[] }
13+
>(),
2014
{
15+
className: "ol-mapzone",
2116
projection: "EPSG:3857",
2217
centerOnClick: true,
2318
}
@@ -26,7 +21,7 @@ const props = withDefaults(
2621
const attrs = useAttrs();
2722
const { properties } = usePropsAsObjectProperties(props);
2823
29-
const { control } = useControl(Zone, properties, attrs);
24+
const { control } = useControl(MapZone, properties, attrs);
3025
3126
defineExpose({
3227
control,

src/demos/AppDemo.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,19 @@ const animationPath = ref(null);
414414
415415
const zones = [
416416
{
417-
title: "Turkey",
418-
extent: [17.952, 46.241, 52.449, 31.222],
417+
title: "France",
418+
extent: [
419+
-5.318421740712579, 41.16082274292913, 9.73284186155716,
420+
51.21957336557702,
421+
],
419422
},
420423
{
421-
title: "Cyprus",
422-
extent: [31.2836, 36.1623, 35.5957, 34.1823],
424+
title: "Turkey",
425+
extent: [22.473435, 34.465842, 43.40239, 42.56525],
423426
},
424427
{
425-
title: "Brazil",
426-
extent: [-120.32, 22.76, 17.67, -47.52],
428+
title: "Germany",
429+
extent: [-0.101752, 47.49888, 20.827203, 54.043465],
427430
},
428431
];
429432

src/demos/ZoneControlDemo.vue

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<template>
2+
<ol-map
3+
ref="map"
4+
:loadTilesWhileAnimating="true"
5+
:loadTilesWhileInteracting="true"
6+
style="height: 400px"
7+
>
8+
<ol-view
9+
ref="view"
10+
:center="center"
11+
:rotation="rotation"
12+
:zoom="zoom"
13+
:projection="projection"
14+
/>
15+
16+
<ol-zone-control
17+
v-if="jawgLayer?.tileLayer"
18+
:zones="zones"
19+
:projection="projection"
20+
:layer="jawgLayer.tileLayer"
21+
>
22+
</ol-zone-control>
23+
24+
<ol-tile-layer ref="jawgLayer" title="JAWG">
25+
<ol-source-xyz
26+
crossOrigin="anonymous"
27+
url="https://c.tile.jawg.io/jawg-dark/{z}/{x}/{y}.png?access-token=87PWIbRaZAGNmYDjlYsLkeTVJpQeCfl2Y61mcHopxXqSdxXExoTLEv7dwqBwSWuJ"
28+
/>
29+
</ol-tile-layer>
30+
</ol-map>
31+
</template>
32+
33+
<script setup>
34+
import { ref } from "vue";
35+
const center = ref([40, 40]);
36+
const projection = ref("EPSG:4326");
37+
const zoom = ref(8);
38+
const rotation = ref(0);
39+
const jawgLayer = ref(null);
40+
41+
const zones = [
42+
{
43+
title: "France",
44+
extent: [
45+
-5.318421740712579, 41.16082274292913, 9.73284186155716,
46+
51.21957336557702,
47+
],
48+
},
49+
{
50+
title: "Turkey",
51+
extent: [22.473435, 34.465842, 43.40239, 42.56525],
52+
},
53+
{
54+
title: "Germany",
55+
extent: [-0.101752, 47.49888, 20.827203, 54.043465],
56+
},
57+
];
58+
</script>

0 commit comments

Comments
 (0)