Skip to content

Commit 67c3f13

Browse files
refactor internal map handling
1 parent 85cb0e7 commit 67c3f13

File tree

1 file changed

+31
-21
lines changed

1 file changed

+31
-21
lines changed

packages/clients/dish/src/polar-client.ts

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable max-lines-per-function */
21
import client from '@polar/core'
32
import merge from 'lodash.merge'
43
import packageInfo from '../package.json'
@@ -9,6 +8,7 @@ import { getMapConfiguration } from './mapConfigurations/mapConfig'
98
import { CONTENT_ENUM } from './plugins/Modal/store'
109
import './styles.css'
1110
import { zoomToFeatureById } from './utils/zoomToFeatureById'
11+
import { DishUrlParams } from './types'
1212

1313
// eslint-disable-next-line no-console
1414
console.log(`DISH map client running in version ${packageInfo.version}.`)
@@ -37,27 +37,9 @@ export default {
3737
// using naming from backend to avoid multiple names for same thing
3838
const objektId = parameters.get('ObjektID')
3939
if (mode === 'INTERN') {
40-
map.subscribe('plugin/export/exportedMap', (screenshot) => {
41-
if (screenshot) {
42-
const newWindow = window.open()
43-
newWindow?.document.write(
44-
`<img src="${screenshot}" alt="Screenshot">`
45-
)
46-
}
47-
})
40+
subscribeToExportedMap(map)
4841
if (typeof objektId === 'string' && objektId !== '') {
49-
zoomToFeatureById(
50-
map,
51-
objektId,
52-
`${urlParams.internServicesBaseUrl}/wfs`,
53-
{
54-
fieldName: 'objektid',
55-
featurePrefix: 'app',
56-
typeName: 'TBLGIS_ORA',
57-
xmlns: 'http://www.deegree.org/app',
58-
useRightHandWildcard: false,
59-
}
60-
)
42+
zoomToInternalFeature(map, objektId, urlParams)
6143
}
6244
} else if (typeof objektId === 'string' && mode === 'EXTERN') {
6345
navigateToDenkmal(map, objektId)
@@ -73,3 +55,31 @@ export default {
7355
})
7456
},
7557
}
58+
59+
function subscribeToExportedMap(instance) {
60+
instance.subscribe('plugin/export/exportedMap', (screenshot) => {
61+
if (screenshot) {
62+
const newWindow = window.open()
63+
newWindow?.document.write(`<img src="${screenshot}" alt="Screenshot">`)
64+
}
65+
})
66+
}
67+
68+
function zoomToInternalFeature(
69+
instance,
70+
objektId: string,
71+
urlParams: DishUrlParams
72+
) {
73+
zoomToFeatureById(
74+
instance,
75+
objektId,
76+
`${urlParams.internServicesBaseUrl}/wfs`,
77+
{
78+
fieldName: 'objektid',
79+
featurePrefix: 'app',
80+
typeName: 'TBLGIS_ORA',
81+
xmlns: 'http://www.deegree.org/app',
82+
useRightHandWildcard: false,
83+
}
84+
)
85+
}

0 commit comments

Comments
 (0)