Skip to content

Commit

Permalink
Ajout du widget FullScreen et OverviewMap
Browse files Browse the repository at this point in the history
  • Loading branch information
lowzonenose committed Jun 20, 2024
1 parent 6d0c35c commit 0bd8c03
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 85 deletions.
Binary file removed geoportal-extensions-openlayers-1.0.0-beta.80.tgz
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@gouvminint/vue-dsfr": "^5.14.2",
"@vueuse/components": "^10.9.0",
"@vueuse/core": "^10.9.0",
"geoportal-extensions-openlayers": "./geoportal-extensions-openlayers-1.0.0-beta.80.tgz",
"geoportal-extensions-openlayers": "./geoportal-extensions-openlayers-1.0.0-beta.81.tgz",
"ol": "8.2.0",
"vue": "^3.4.21",
"vue-router": "^4.3.0"
Expand Down
54 changes: 21 additions & 33 deletions src/components/carte/Control.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="js">
import TileLayer from 'ol/layer/Tile.js'
import OSM from 'ol/source/OSM'
Expand All @@ -18,11 +17,11 @@ const props = defineProps({
})
const layerSwitcherOptions = {
options : {
options: {
// position : "top-right",
collapsed : true,
panel : true,
counter : true
collapsed: true,
panel: true,
counter: true
}
}
Expand All @@ -42,46 +41,35 @@ const searchEngineOptions = {
search: true
},
searchOptions: {
addToMap : false,
serviceOptions : {
services: "WMTS,WMS,TMS"
addToMap: false,
serviceOptions: {
services: 'WMTS,WMS,TMS'
}
}
}
const overviewMapOptions = {
className: 'ol-overviewmap ol-custom-overviewmap',
collapseLabel: '',
label: '',
collapsed: true,
layers : [
new TileLayer({
source: new OSM(),
})
]
position: 'bottom-left'
}
const zoomOptions = {
position : "bottom-right",
position: 'bottom-right',
}
const attributionsOptions = {}
// FIXME exception
// FIXME exception sur la position
const isocurveOptions = {
position : "bottom-right"
position: 'bottom-right'
}
const reverseGeocodeOptions = {
position : "bottom-right"
position: 'bottom-right'
}
const fullscreenOptions = {
className: "ol-custom-full-screen",
label : "",
labelActive : ""
position: 'bottom-right'
}
</script>

<template>
Expand All @@ -97,6 +85,10 @@ const fullscreenOptions = {
:visibility="props.controlOptions.includes(useControls.ReverseGeocode.id)"
:reverse-geocode-options="reverseGeocodeOptions"
/>
<FullScreen
:visibility="props.controlOptions.includes(useControls.FullScreen.id)"
:fullscreen-options="fullscreenOptions"
/>
<Zoom
:visibility="props.controlOptions.includes(useControls.Zoom.id)"
:zoom-options="zoomOptions"
Expand All @@ -117,20 +109,16 @@ const fullscreenOptions = {
:visibility="props.controlOptions.includes(useControls.OverviewMap.id)"
:overview-map-options="overviewMapOptions"
/>
<FullScreen
:visibility="props.controlOptions.includes(useControls.FullScreen.id)"
:fullscreen-options="fullscreenOptions"
/>
</template>

<style>
.position-container-bottom-left,
.position-container-bottom-right,
.position-container-top-left,
.position-container-bottom-left,
.position-container-bottom-right,
.position-container-top-left,
.position-container-top-right {
border-style: unset;
}
.position-container-top-right {
top: 90px;
}
</style>
</style>
26 changes: 3 additions & 23 deletions src/components/carte/control/FullScreen.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script setup lang="js">
import FullScreen from 'ol/control/FullScreen'
import { GeoportalFullScreen } from 'geoportal-extensions-openlayers'
const props = defineProps({
visibility: Boolean,
fullscreenOptions: Object
})
const map = inject('map')
const fullscreen = ref(new FullScreen(props.fullscreenOptions))
const fullscreen = ref(new GeoportalFullScreen(props.fullscreenOptions))
onMounted(() => {
if (props.visibility) {
Expand All @@ -24,27 +23,8 @@ onBeforeUpdate(() => {
map.removeControl(fullscreen.value)
}
})
</script>

<template></template>

<style>
#map .ol-custom-full-screen {
bottom: 54px;
left: 5px;
}
/* surcharge en mode dsfr */
.ol-custom-full-screen button {
height: 40px;
width: 40px;
background-color: #000091;
background-image: url("../../../assets/fullscreen.svg");
background-position: center center;
background-repeat: no-repeat;
}
.ol-custom-full-screen button:hover {
background-color: #1212ff;
}
</style>
<style></style>
38 changes: 13 additions & 25 deletions src/components/carte/control/OverviewMap.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
<script setup lang="js">
import { useMatchMedia } from '@/composables/matchMedia';
import OverviewMap from 'ol/control/OverviewMap'
import { useLogger } from 'vue-logger-plugin'
import { GeoportalOverviewMap } from 'geoportal-extensions-openlayers'
import { useMatchMedia } from '@/composables/matchMedia'
const props = defineProps({
visibility: Boolean,
overviewMapOptions: Object
})
const log = useLogger()
const map = inject('map')
const overviewMap = ref(new OverviewMap(props.overviewMapOptions))
const overviewMap = ref(new GeoportalOverviewMap(props.overviewMapOptions))
const isSmallScreen = useMatchMedia("SM")
const isSmallScreen = useMatchMedia('SM')
watch(isSmallScreen, () => {
if (props.visibility && !isSmallScreen.value) {
Expand All @@ -20,11 +22,12 @@ watch(isSmallScreen, () => {
else {
map.removeControl(overviewMap.value)
}
})
})
onMounted(() => {
if (props.visibility && !isSmallScreen.value) {
map.addControl(overviewMap.value)
overviewMap.value.on('overviewmap:toggle', onToggleOverviewMap)
}
})
Expand All @@ -37,26 +40,11 @@ onBeforeUpdate(() => {
}
})
function onToggleOverviewMap (e) {
log.debug(e)
}
</script>

<template></template>

<style>
#map .ol-custom-overviewmap {
bottom: 10px;
left: 5px;
}
/* surcharge en mode dsfr */
.ol-custom-overviewmap button {
height: 40px;
width: 40px;
background-color: #000091;
background-image: url("../../../assets/map.svg");
background-position: center center;
background-repeat: no-repeat;
}
.ol-custom-overviewmap button:hover {
background-color: #1212ff;
}
</style>
<style></style>
18 changes: 15 additions & 3 deletions src/components/carte/control/Zoom.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="js">
import {
import { useLogger } from 'vue-logger-plugin'
import {
GeoportalZoom
} from 'geoportal-extensions-openlayers'
Expand All @@ -9,12 +9,16 @@ const props = defineProps({
zoomOptions: Object
})
const log = useLogger()
const map = inject('map')
const zoom = ref(new GeoportalZoom(props.zoomOptions))
onMounted(() => {
if (props.visibility) {
map.addControl(zoom.value)
zoom.value.on('zoom:in', onClickZoomIn)
zoom.value.on('zoom:out', onClickZoomOut)
}
})
Expand All @@ -29,10 +33,18 @@ onUpdated(() => {
map.addControl(zoom.value)
}
})
function onClickZoomIn (e) {
log.debug(e)
}
function onClickZoomOut (e) {
log.debug(e)
}
</script>

<template></template>

<style scoped>
/* TODO style DSFR */
</style>
</style>

0 comments on commit 0bd8c03

Please sign in to comment.