Skip to content

Commit dba0603

Browse files
authored
Merge pull request #29 from camptocamp/maplibre
Add Maplibre package
2 parents 17bad88 + 117b45b commit dba0603

27 files changed

+1640
-17
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
},
2727
"plugins": ["@typescript-eslint", "vue"],
2828
"rules": {
29-
"@typescript-eslint/no-explicit-any": 1
29+
"@typescript-eslint/no-explicit-any": 1,
30+
"no-prototype-builtins": "off"
3031
},
3132
"ignorePatterns": ["**/*.test.ts", "apps", "**/mocks", "**/dist/**"]
3233
}

apps/examples/src/App.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import ExampleZoomToLayerRaw from '@/examples/Example-ZoomToLayer.vue?raw'
1111
import ExampleMapEvents from '@/examples/Example-MapEvents.vue'
1212
import ExampleMapEventsRaw from '@/examples/Example-MapEvents.vue?raw'
1313
import ExampleCustomElementsHtml from '@/examples/Example-CustomElements.html?raw'
14+
import ExampleMaplibreRaw from '@/examples/Example-Maplibre.vue?raw'
15+
import ExampleMaplibre from '@/examples/Example-Maplibre.vue'
1416
import { onMounted, ref } from 'vue'
1517
import hljs from 'highlight.js'
1618
import '@geospatial-sdk/elements'
@@ -29,7 +31,9 @@ function loadHtmlExample(html: string, root: HTMLElement) {
2931
3032
const example06_root = ref<HTMLElement>()
3133
onMounted(() => {
32-
loadHtmlExample(ExampleCustomElementsHtml as string, example06_root.value!)
34+
if (example06_root.value) {
35+
loadHtmlExample(ExampleCustomElementsHtml as string, example06_root.value)
36+
}
3337
hljs.highlightAll()
3438
})
3539
</script>
@@ -85,6 +89,13 @@ onMounted(() => {
8589
>
8690
<div class="w-full h-full" ref="example06_root"></div>
8791
</ExampleContainer>
92+
<ExampleContainer
93+
example-name="Example 7: Maplibre"
94+
example-id="example07"
95+
:source-code="ExampleMaplibreRaw"
96+
>
97+
<ExampleMaplibre></ExampleMaplibre>
98+
</ExampleContainer>
8899
</div>
89100
</template>
90101

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<script setup lang="ts">
2+
import { onMounted, ref } from 'vue'
3+
import { createMapFromContext } from '@geospatial-sdk/maplibre'
4+
import { type MapContext, type MapContextLayerWms } from '@geospatial-sdk/core'
5+
6+
const Layers = {
7+
maplibre: {
8+
type: 'maplibre-style',
9+
styleUrl: 'https://demo.baremaps.com/style.json',
10+
accessToken: 'abcdefgh'
11+
},
12+
wms: {
13+
type: 'wms',
14+
url: 'https://data.geopf.fr/wms-r/wms',
15+
name: 'INSEE.FILOSOFI.POPULATION'
16+
} as MapContextLayerWms,
17+
wfs: {
18+
type: 'wfs',
19+
url: 'https://data.lillemetropole.fr/geoserver/dsp_ilevia/ows?REQUEST=GetCapabilities&SERVICE=WFS&VERSION=2.0.0',
20+
featureType: 'ilevia_traceslignes',
21+
label: 'Tracé des lignes de bus',
22+
visibility: true,
23+
attributions: 'camptocamp',
24+
opacity: 0.5
25+
},
26+
geojson: {
27+
id: 'geojson',
28+
type: 'geojson',
29+
url: 'https://data.lillemetropole.fr/data/ogcapi/collections/roubaix:implantation_des_arceaux_velos_a_roubaix/items?f=geojson&limit=-1'
30+
},
31+
ogcapi: {
32+
type: 'ogcapi',
33+
url: 'https://data.lillemetropole.fr/data/ogcapi/collections/ilevia:abris_velo/items?f=json&limit=-1',
34+
collection: 'ilevia:abris_velo'
35+
}
36+
}
37+
38+
const mapRoot = ref<HTMLElement>()
39+
let context = {
40+
view: {
41+
zoom: 10,
42+
center: [3.1626248124366176, 50.67829080457065]
43+
},
44+
layers: Object.keys(Layers).map(key => Layers[key as keyof typeof Layers])
45+
}
46+
47+
onMounted(async () => {
48+
await createMapFromContext(<MapContext>context, {
49+
container: <HTMLElement>mapRoot.value
50+
})
51+
})
52+
53+
</script>
54+
55+
<template>
56+
<div ref="mapRoot" class="w-full h-full relative">
57+
<div class="absolute inset-x-4 bottom-4 flex flex-row gap-4 z-50">
58+
</div>
59+
</div>
60+
</template>

apps/examples/src/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@import 'ol/ol.css';
2-
2+
@import 'maplibre-gl/dist/maplibre-gl.css';
33
@tailwind base;
44
@tailwind components;
55
@tailwind utilities;

0 commit comments

Comments
 (0)