Skip to content

Commit

Permalink
[POC] print vectortiles : print mode
Browse files Browse the repository at this point in the history
adding a flag making OL requests next zoom level tiles when in between zoom levels
  • Loading branch information
pakb committed Jan 21, 2025
1 parent 9ebe51b commit efe4062
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const { wmtsLayerConfig, parentLayerOpacity, zIndex } = toRefs(props)
// mapping relevant store values
const store = useStore()
const projection = computed(() => store.state.position.projection)
const printMode = computed(() => store.state.map.printMode)
// extracting useful info from what we've linked so far
const layerId = computed(() => wmtsLayerConfig.value.technicalName)
const maxResolution = computed(() => wmtsLayerConfig.value.maxResolution)
Expand Down Expand Up @@ -73,6 +74,7 @@ watch(wmtsTimeConfig, () => {
log.debug('Update wmts dimension', wmtsTimeConfig.value)
layer.getSource().updateDimensions(wmtsTimeConfig.value.dimensions)
})
watch(printMode, () => layer.setSource(createWMTSSourceForProjection()))
function getTransformedXYZUrl() {
return getWmtsXyzUrl(wmtsLayerConfig.value, projection.value)
Expand Down Expand Up @@ -110,7 +112,11 @@ function createTileGridForProjection() {
*/
function createWMTSSourceForProjection() {
log.debug('Create new WMTS source for projection', wmtsSourceConfig.value, wmtsTimeConfig.value)
return new WMTSSource({ ...wmtsSourceConfig.value, ...wmtsTimeConfig.value })
return new WMTSSource({
...wmtsSourceConfig.value,
...wmtsTimeConfig.value,
zDirection: printMode.value ? -1 : 0,
})
}
</script>
Expand Down
10 changes: 10 additions & 0 deletions src/router/storeSync/storeSync.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ const storeSyncConfig = [
validateUrlInput: null,
}),
new TimeSliderParamConfig(),
new SimpleUrlParamConfig({
urlParamName: 'printMode',
mutationsToWatch: ['setPrintMode'],
dispatchName: 'setPrintMode',
dispatchValueName: 'mode',
extractValueFromStore: (store) => store.state.map.printMode,
keepInUrlWhenDefault: false,
valueType: Boolean,
defaultValue: false,
}),
createBaseUrlOverrideParamConfig({ urlParamName: 'wms_url', baseUrlPropertyName: 'wms' }),
createBaseUrlOverrideParamConfig({ urlParamName: 'wmts_url', baseUrlPropertyName: 'wmts' }),
createBaseUrlOverrideParamConfig({ urlParamName: 'api_url', baseUrlPropertyName: 'api3' }),
Expand Down
9 changes: 9 additions & 0 deletions src/store/modules/map.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export default {
* @type Array<Number>
*/
locationPopupCoordinates: null,
/**
* Tells if the map is in print mode, meaning it will jump to a higher zoom level early.
*
* @type Boolean
*/
printMode: false,
},
actions: {
/**
Expand Down Expand Up @@ -123,6 +129,8 @@ export default {
commit('setLocationPopupCoordinates', { coordinates: null, dispatcher })
}
},
setPrintMode: ({ commit }, { mode, dispatcher }) =>
commit('setPrintMode', { mode: !!mode, dispatcher }),
},
mutations: {
setClickInfo: (state, { clickInfo }) => (state.clickInfo = clickInfo),
Expand All @@ -131,5 +139,6 @@ export default {
(state.previewedPinnedLocation = coordinates),
setLocationPopupCoordinates: (state, { coordinates }) =>
(state.locationPopupCoordinates = coordinates),
setPrintMode: (state, { mode }) => (state.printMode = mode),
},
}

0 comments on commit efe4062

Please sign in to comment.