-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from camptocamp/add-feature-clicked-event
Add basic click/hover events on the OpenLayers map
- Loading branch information
Showing
53 changed files
with
856 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Quality Assurance | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, ready_for_review] | ||
|
||
jobs: | ||
format-typecheck-test: | ||
name: Formatting, types and tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Node & NPM | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'npm' | ||
|
||
- name: Install lib dependencies | ||
run: npm ci | ||
|
||
- name: Formatting | ||
run: npm run format:check | ||
|
||
- name: Type check | ||
run: npm run typecheck | ||
|
||
- name: Linting | ||
run: npm run lint | ||
|
||
- name: Run tests | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
**/.vitepress/cache | ||
**/.vitepress/dist | ||
packages/*/dist | ||
.idea | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script setup lang="ts"></script> | ||
|
||
<template> | ||
<div class="p-3 text-xs text-gray-900 bg-white rounded-md shadow-xl"> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<script setup lang="ts"> | ||
import { onMounted, ref } from 'vue' | ||
import Map from 'ol/Map' | ||
import { createMapFromContext, listen } from '@geospatial-sdk/openlayers' | ||
import type { FeaturesHoverEvent, MapClickEvent, MapContext } from '@geospatial-sdk/core' | ||
import { DEFAULT_CONTEXT } from '@/constants' | ||
import Panel from '@/components/Panel.vue' | ||
import type { Feature } from 'geojson' | ||
const Layers = { | ||
wms: { | ||
type: 'wms', | ||
url: 'https://ows.emodnet-bathymetry.eu/wms', | ||
name: 'emodnet:mean_rainbowcolour' | ||
}, | ||
geojson: { | ||
type: 'geojson', | ||
url: 'https://france-geojson.gregoiredavid.fr/repo/regions.geojson' | ||
} | ||
} | ||
const mapRoot = ref<HTMLElement>() | ||
let map: Map | ||
let context = { | ||
...DEFAULT_CONTEXT, | ||
layers: [...DEFAULT_CONTEXT.layers, Layers.wms, Layers.geojson] | ||
} as MapContext | ||
let features = ref<Feature[]>([]) | ||
let clickCoordinates = ref<[number, number] | null>(null) | ||
onMounted(async () => { | ||
map = await createMapFromContext(context, mapRoot.value) | ||
listen(map, 'features-hover', (event: FeaturesHoverEvent) => (features.value = event.features)) | ||
listen(map, 'map-click', (event: MapClickEvent) => (clickCoordinates.value = event.coordinate)) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div ref="mapRoot" class="w-full h-full relative"> | ||
<div class="absolute top-3 right-3 flex flex-col gap-3 z-50 w-56"> | ||
<Panel v-if="clickCoordinates"> | ||
<strong>Last click coordinates</strong> | ||
{{ clickCoordinates.join(', ') }} | ||
</Panel> | ||
<Panel v-for="(feature, index) in features" v-bind:key="index"> | ||
<h4 class="font-bold mb-1">Feature</h4> | ||
<ul> | ||
<li v-for="(value, key) in feature.properties" v-bind:key="key"> | ||
<strong>{{ key }}</strong | ||
>: {{ value }} | ||
</li> | ||
</ul> | ||
</Panel> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.