-
Notifications
You must be signed in to change notification settings - Fork 0
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 #212 from IGNF/feature/layer-manager
feat(menu) : gestion des menus autour de la carte
- Loading branch information
Showing
28 changed files
with
1,238 additions
and
200 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
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 |
---|---|---|
@@ -1,27 +1,23 @@ | ||
<script setup lang="js"> | ||
import { useLogger } from 'vue-logger-plugin' | ||
import { storeToRefs } from 'pinia' | ||
import { useDataStore } from "@/stores/dataStore" | ||
const props = defineProps({}) | ||
const log = useLogger() | ||
const store = useDataStore() | ||
const { getLayers } = storeToRefs(store) | ||
const storeData = useDataStore() | ||
// INFO | ||
// l'opération est asynchrone, il faut donc attendre que le store soit chargé | ||
// avant d'initialiser la carte. | ||
await store.fetchData() | ||
if (store.isLoaded) { | ||
log.debug(toRaw(getLayers.value)) | ||
} | ||
const { fetchData } = storeData; | ||
const res = await fetchData(); | ||
log.debug(res); | ||
</script> | ||
|
||
<template> | ||
<!-- TODO mettre en place une patience --> | ||
<slot v-if="storeData.isLoaded && !storeData.error"></slot> | ||
</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,37 @@ | ||
<script setup lang="js"> | ||
import Map from '@/components/carte/Map.vue' | ||
import View from '@/components/carte/View.vue' | ||
import Control from '@/components/carte/Control.vue' | ||
import LayerManager from '@/components/carte/Layer/LayerManager.vue' | ||
import { useMapStore } from "@/stores/mapStore" | ||
const props = defineProps({ | ||
selectedControls : Array, | ||
layersList : Object, | ||
mapWidth: Number | ||
}) | ||
const mapStore = useMapStore() | ||
</script> | ||
|
||
<template> | ||
<Map | ||
:width="props.mapWidth"> | ||
<View | ||
:center="mapStore.center" | ||
:zoom="mapStore.zoom"/> | ||
<Control | ||
v-if="selectedControls" | ||
:control-options="props.selectedControls"/> | ||
<!-- FIXME c'est un composant pour l'exemple | ||
donc provisoire ! --> | ||
<LayerManager | ||
:layers-list="props.layersList"/> | ||
</Map> | ||
</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
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,28 @@ | ||
<script setup lang="js"> | ||
// FIXME c'est pour l'exemple car les couches sont gérées par les extensions ! | ||
// cf. LayerManager | ||
import TileLayer from 'ol/layer/Tile.js' | ||
const props = defineProps({ | ||
layerOptions: Object | ||
}) | ||
const map = inject('map') | ||
const layer = ref(new TileLayer(props.layerOptions)) | ||
onMounted(() => { | ||
map?.addLayer(layer.value) | ||
}) | ||
onUnmounted(() => { | ||
map?.removeLayer(layer.value) | ||
}) | ||
</script> | ||
<template> | ||
<div> | ||
<slot></slot> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script setup lang="js"> | ||
// FIXME c'est juste pour l'exemple car on va ajouter l'extension LayerSwitcher ! | ||
// Donc provisoire... | ||
import Layer from '@/components/carte/Layer/Layer.vue' | ||
import { resolutions } from '@/composables/layers' | ||
import WMTS from 'ol/source/WMTS.js'; | ||
import WMTSTileGrid from 'ol/tilegrid/WMTS'; | ||
const props = defineProps({ | ||
layersList: Object | ||
}) | ||
var layersConfList = computed(() => {return toRaw(props.layersList).map(layername => addWMTSLayer(layername))}); | ||
function addWMTSLayer(layer) { | ||
if (layer && Object.keys(layer).length) { | ||
const startRes = Object.keys(layer.wmtsOptions.tileMatrixSetLimits)[0] | ||
const endRes = Object.keys(layer.wmtsOptions.tileMatrixSetLimits).slice(-1) | ||
const sourceOptions = { | ||
url: 'https://wmts.geopf.fr/wmts', | ||
layer: layer.name, | ||
matrixSet: layer.wmtsOptions.tileMatrixSetLink, | ||
projection: layer.defaultProjection, | ||
format: layer.formats[0].name, | ||
style: layer.styles[0].name, | ||
tileGrid : new WMTSTileGrid({ | ||
origin: [-20037508,20037508], // topLeftCorner | ||
resolutions: resolutions.slice(startRes, endRes), // résolutions | ||
matrixIds: Object.keys(layer.wmtsOptions.tileMatrixSetLimits) // ids des TileMatrix | ||
}) | ||
}; | ||
var source = new WMTS(sourceOptions); | ||
source._title = layer.name; | ||
return { | ||
source : source, | ||
opacity: 1 | ||
} | ||
} | ||
else return {} | ||
} | ||
</script> | ||
|
||
<template> | ||
<Layer | ||
v-for="layer in layersConfList" | ||
:layer-options="layer" | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,7 @@ provide('map', map) | |
|
||
<style> | ||
#map { | ||
margin-left: 0; | ||
width: inherit; | ||
height: 70vh; | ||
height: inherit; | ||
} | ||
</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
Oops, something went wrong.