Skip to content

Commit

Permalink
Implement map view via Leaflet
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Jun 26, 2024
1 parent 44e6d61 commit 16edbdd
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
},
"dependencies": {
"@intlify/unplugin-vue-i18n": "^4.0.0",
"@vue-leaflet/vue-leaflet": "^0.10.1",
"axios": "^1.7.2",
"cocoda-sdk": "^3.4.8",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"jskos-tools": "^1.0.37",
"jskos-vue": "^0.3.5",
"jsonld": "^8.3.2",
"leaflet": "^1.9.4",
"portfinder": "^1.0.32",
"rdflib": "^2.2.35",
"vite-express": "^0.16.0",
Expand Down
29 changes: 29 additions & 0 deletions src/client/components/MapView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script setup>
defineProps({
longitude: Number,
latitude: Number,
})
import "leaflet/dist/leaflet.css"
import { LMap, LTileLayer, LMarker } from "@vue-leaflet/vue-leaflet"
import { ref } from "vue"
const zoom = ref(8)
</script>

<template>
<div style="height: 300px">
<l-map
ref="map"
v-model:zoom="zoom"
:center="[latitude, longitude]"
:use-global-leaflet="false">
<l-tile-layer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
layer-type="base"
name="OpenStreetMap"
attribution="&copy; <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>" />
<l-marker :lat-lng="[latitude, longitude]" />
</l-map>
</div>
</template>
9 changes: 9 additions & 0 deletions src/client/views/ItemView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { schemes, registry, loadTop, loadNarrower, loadConcept, loadAncestors, s
import { computed, ref, watch } from "vue"
import { useRoute, useRouter } from "vue-router"
import { utils } from "jskos-vue"
import MapView from "@/components/MapView.vue"
import { getRouterUrl } from "@/utils.js"
const route = useRoute()
const router = useRouter()
Expand Down Expand Up @@ -138,6 +140,13 @@ const topConcepts = computed(() => {
<pre><code>{{ JSON.stringify(jskos.deepCopy(concept || scheme, ["topConceptOf", "inScheme", "topConcepts"]), null, 2) }}
</code></pre>
</tab>
<tab
v-if="concept?.location?.coordinates?.length"
title="Map">
<MapView
:longitude="concept.location.coordinates[0]"
:latitude="concept.location.coordinates[1]" />
</tab>
</template>
</item-details>
</div>
Expand Down

0 comments on commit 16edbdd

Please sign in to comment.