Skip to content

Commit a6cb11e

Browse files
committed
Add GeoJson example to playground
1 parent 7c6c27c commit a6cb11e

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

playground/app.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
<NuxtLink to="/">Home</NuxtLink>
77
</li>
88
<li>
9-
<NuxtLink to="/map/search">Map</NuxtLink>
9+
<NuxtLink to="/map/map">Map</NuxtLink>
10+
</li>
11+
<li>
12+
<NuxtLink to="/map/geojson">GeoJson</NuxtLink>
1013
</li>
1114
</ul>
1215
</nav>

playground/pages/map/geojson.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
<div style="height:100vh; width:100vw">
3+
<h1>GeoJson Example</h1>
4+
<LMap
5+
:zoom="zoom"
6+
:max-zoom="18"
7+
:center="[47.21322, -1.559482]"
8+
>
9+
<LTileLayer
10+
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
11+
attribution="&amp;copy; <a href=&quot;https://www.openstreetmap.org/&quot;>OpenStreetMap</a> contributors"
12+
layer-type="base"
13+
name="OpenStreetMap"
14+
/>
15+
<LGeoJson
16+
:geojson="geojson"
17+
:options-style="geoStyler"
18+
/>
19+
</LMap>
20+
</div>
21+
</template>
22+
23+
<script setup>
24+
import { ref, onMounted } from 'vue'
25+
const zoom = ref(6)
26+
const geojson = ref(undefined)
27+
const geoStyler = (feature) => ({
28+
opacity: feature.properties.code / 100000,
29+
})
30+
31+
onMounted(async () => {
32+
const response = await fetch(
33+
"https://rawgit.com/gregoiredavid/france-geojson/master/regions/pays-de-la-loire/communes-pays-de-la-loire.geojson"
34+
);
35+
geojson.value = await response.json();
36+
});
37+
</script>
File renamed without changes.

0 commit comments

Comments
 (0)