Skip to content

Commit

Permalink
fix(ol-webgl-vector-layer): call make properties reactive
Browse files Browse the repository at this point in the history
closes #355
  • Loading branch information
d-koppenhagen committed Jun 10, 2024
1 parent 479d765 commit 3e77dfe
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/components/layers/OlWebglVectorLayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ const props = withDefaults(
},
);
const { layer } = useLayer(WebGLVectorLayer, {
...props,
});
const { layer } = useLayer(WebGLVectorLayer, props);
provide("webglVectorLayer", layer);
Expand Down
42 changes: 38 additions & 4 deletions src/demos/WebglVectorLayerDemo.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<template>
<form>
<fieldset>
<label for="opacity">Layer Opacity</label>
<input
type="range"
id="opacity"
min="0"
max="1"
step="0.1"
v-model.number="opacity"
/>
<span class="description">{{ opacity }}</span>
</fieldset>
<fieldset>
<label for="visibility-toggle">Layer Visibility:</label>
<input type="checkbox" id="visibility-toggle" v-model="visible" />
<span> {{ visible ? "Visible" : "Hidden" }}</span>
</fieldset>
</form>

<ol-map
:loadTilesWhileAnimating="true"
:loadTilesWhileInteracting="true"
Expand All @@ -16,7 +36,11 @@
</ol-tile-layer>

<!-- webgl points layer -->
<ol-webgl-vector-layer :styles="webglPointStyle">
<ol-webgl-vector-layer
:styles="webglPointStyle"
:visible="visible"
:opacity="opacity"
>
<ol-source-vector
:format="geoJson"
crossOrigin="anonymous"
Expand All @@ -25,7 +49,11 @@
</ol-webgl-vector-layer>

<!-- webgl lines layer -->
<ol-webgl-vector-layer :styles="webglLineStyle">
<ol-webgl-vector-layer
:styles="webglLineStyle"
:visible="visible"
:opacity="opacity"
>
<ol-source-vector
:format="geoJson"
crossOrigin="anonymous"
Expand All @@ -34,7 +62,11 @@
</ol-webgl-vector-layer>

<!-- webgl polygons layer -->
<ol-webgl-vector-layer :styles="webglPolyStyle">
<ol-webgl-vector-layer
:styles="webglPolyStyle"
:visible="visible"
:opacity="opacity"
>
<ol-source-vector
:format="geoJson"
crossOrigin="anonymous"
Expand All @@ -45,8 +77,10 @@
</template>

<script setup lang="ts">
import { ref, inject } from "vue";
import { inject, ref } from "vue";
const opacity = ref(1);
const visible = ref(true);
const center = ref([-73.3, 48.0]);
const projection = ref("EPSG:4326");
const zoom = ref(7);
Expand Down
18 changes: 17 additions & 1 deletion src/demos/WebglVectorSourceDemo.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<template>
<form>
<fieldset>
<label for="opacity">Layer Opacity</label>
<input
type="range"
id="opacity"
min="0"
max="1"
step="0.1"
v-model.number="opacity"
/>
<span class="description">{{ opacity }}</span>
</fieldset>
</form>

<ol-map
:loadTilesWhileAnimating="true"
:loadTilesWhileInteracting="true"
Expand Down Expand Up @@ -45,8 +60,9 @@
</template>

<script setup lang="ts">
import { ref, inject } from "vue";
import { inject, ref } from "vue";
const opacity = ref(1);
const center = ref([116.54875, 40.45064]);
const projection = ref("EPSG:4326");
const zoom = ref(16);
Expand Down

0 comments on commit 3e77dfe

Please sign in to comment.