Skip to content

Commit 4d44b21

Browse files
committed
refactor(ol-webgl-tile-layer): adopt OpenLayers API and fix layers rendering
BREAKING CHANGE: - **`ol-webgl-tile-layer`** use [props and default values from openlayers directly](https://openlayers.org/en/latest/apidoc/module-ol_layer_WebGLTile-WebGLTileLayer.html)
1 parent 78dc2c6 commit 4d44b21

File tree

3 files changed

+40
-81
lines changed

3 files changed

+40
-81
lines changed

Diff for: docs/componentsguide/layers/webgltilelayer/index.md

+37-51
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,67 @@
33
This example uses WebGL to raster tiles on a map.
44

55
<script setup>
6-
import WebglTileLayerDemo from "@demos/WebglTileLayerDemo.vue"
6+
import GeoTIFFDemo from "@demos/GeoTIFFDemo.vue"
77
</script>
88
<ClientOnly>
9-
<WebglTileLayerDemo />
9+
<GeoTIFFDemo />
1010
</ClientOnly>
1111

1212
## Usage
1313

1414
::: code-group
1515

16-
<<< ../../../../src/demos/WebglTileLayerDemo.vue
16+
<<< ../../../../src/demos/GeoTIFFDemo.vue
1717

1818
:::
1919

2020
## Properties
2121

22-
### className
22+
### Props from OpenLayers
2323

24-
- **Type**: `string`
25-
- **Default**: `ol-layer`
24+
Properties are passed-trough from OpenLayers directly.
25+
Their types and default values can be checked-out [in the official OpenLayers docs](https://openlayers.org/en/latest/apidoc/module-ol_layer_WebGLTile-WebGLTileLayer.html).
26+
Only some properties deviate caused by reserved keywords from Vue / HTML.
27+
This deviating props are described in the section below.
2628

27-
A CSS class name to set to the layer element.
29+
### Deviating Properties
2830

29-
### opacity
31+
**`visible`**
3032

31-
- **Type**: `number `
32-
- **Default**: `1`
33+
The value for `visible` is set to `true` by default.
3334

34-
Opacity (0, 1).
35+
## Events
3536

36-
### visible
37+
You have access to all Events from the underlying source.
38+
Check out [the official OpenLayers docs](https://openlayers.org/en/latest/apidoc/module-ol_layer_WebGLTile-WebGLTileLayer.html) to see the available events tht will be fired.
3739

38-
- **Type**: `boolean`
39-
- **Default**: `true`
40+
```html
41+
<ol-webgl-tile-layer @error="handleEvent" />
42+
```
4043

41-
Visibility.
44+
## Methods
4245

43-
### extent
46+
You have access to all Methods from the underlying source.
47+
Check out [the official OpenLayers docs](https://openlayers.org/en/latest/apidoc/module-ol_layer_WebGLTile-WebGLTileLayer.html) to see the available methods.
4448

45-
- **Type**: `Array`
49+
To access the source, you can use a `ref()` as shown below:
4650

47-
The bounding extent for layer rendering. The layer will not be rendered outside of this extent.
51+
```vue
52+
<template>
53+
<!-- ... -->
54+
<ol-webgl-tile-layer ref="layerRef" />
55+
<!-- ... -->
56+
</template>
4857
49-
### zIndex
58+
<script setup lang="ts">
59+
import { ref, onMounted } from "vue";
60+
import type WebGLTileLayer from "ol/layer/WebGLTile";
5061
51-
- **Type**: `number`
62+
const layerRef = ref<{ tileLayer: WebGLTileLayer }>(null);
5263
53-
The z-index for layer rendering. At rendering time, the layers will be ordered, first by Z-index and then by position.
54-
55-
### minResolution
56-
57-
- **Type**: `number`
58-
59-
The minimum resolution (inclusive) at which this layer will be visible.
60-
61-
### maxResolution
62-
63-
- **Type**: `number`
64-
65-
The maximum resolution (exclusive) below which this layer will be visible.
66-
67-
### minZoom
68-
69-
- **Type**: `number`
70-
71-
The minimum view zoom level (exclusive) above which this layer will be visible.
72-
73-
### maxZoom
74-
75-
- **Type**: `number`
76-
77-
The maximum view zoom level (inclusive) at which this layer will be visible.
78-
79-
### preload
80-
81-
- **Type**: `number`
82-
- **Default**: `0`
83-
Low-resolution tiles up to preload level will be load.
64+
onMounted(() => {
65+
const layer: WebGLTileLayer = sourceRef.value?.tileLayer;
66+
// call your method on `layer`
67+
});
68+
</script>
69+
```

Diff for: src/components/layers/OlWebglTileLayer.vue

+3-9
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@
77
<script setup lang="ts">
88
import type { Ref } from "vue";
99
import { inject, provide, onUnmounted, onMounted, watch, computed } from "vue";
10-
import TileLayer from "ol/layer/WebGLTile";
10+
import TileLayer, { type Options } from "ol/layer/WebGLTile";
1111
import type Map from "ol/Map";
1212
import type { OverviewMap } from "ol/control";
1313
import usePropsAsObjectProperties from "@/composables/usePropsAsObjectProperties";
1414
import {
1515
layersCommonDefaultProps,
16-
type LayersCommonProps,
1716
} from "@/components/layers/LayersCommonProps";
1817
import type LayerGroup from "ol/layer/Group";
1918
2019
const props = withDefaults(
21-
defineProps<
22-
LayersCommonProps & {
23-
preload?: number;
24-
}
25-
>(),
20+
defineProps<Options>(),
2621
{
27-
...layersCommonDefaultProps,
28-
preload: 1,
22+
visible: true,
2923
},
3024
);
3125

Diff for: src/demos/WebglTileLayerDemo.vue

-21
This file was deleted.

0 commit comments

Comments
 (0)