Skip to content

Commit 896f418

Browse files
authored
Merge pull request #188 from Dataport/feature/direct-export
Additionally expose createMap for @polar/client-generic
2 parents ee74abb + 784d9e8 commit 896f418

File tree

3 files changed

+40
-34
lines changed

3 files changed

+40
-34
lines changed

packages/clients/generic/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## unpublished
4+
5+
- Feature: Directly expose `createMap` to be able to import it directly when using this client.
6+
37
## 1.0.0
48

59
Initial release.

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

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -156,38 +156,40 @@ const addPlugins = (coreInstance: PolarCore, enabledPlugins: PluginName[]) => {
156156
)
157157
}
158158

159-
export default {
160-
createMap: ({
161-
containerId,
162-
services,
163-
mapConfiguration,
164-
enabledPlugins = [],
165-
modifyLayerConfiguration = (x) => x,
166-
}: {
167-
containerId: string
168-
services: object[]
169-
mapConfiguration: MapConfig
170-
enabledPlugins: Array<PluginName>
171-
modifyLayerConfiguration: (layerConf: object[]) => object[]
172-
}) =>
173-
new Promise((resolve) => {
174-
const coreInstance = { ...core }
159+
export const createMap = ({
160+
containerId,
161+
services,
162+
mapConfiguration,
163+
enabledPlugins = [],
164+
modifyLayerConfiguration = (x) => x,
165+
}: {
166+
containerId: string
167+
services: object[]
168+
mapConfiguration: MapConfig
169+
enabledPlugins: Array<PluginName>
170+
modifyLayerConfiguration: (layerConf: object[]) => object[]
171+
}) =>
172+
new Promise((resolve) => {
173+
const coreInstance = { ...core }
174+
175+
addPlugins(coreInstance, enabledPlugins)
175176

176-
addPlugins(coreInstance, enabledPlugins)
177+
coreInstance.rawLayerList.initializeLayerList(
178+
services,
179+
async (layerConf) => {
180+
const client = await coreInstance.createMap({
181+
containerId,
182+
mapConfiguration: {
183+
...mapConfiguration,
184+
layerConf: modifyLayerConfiguration(layerConf),
185+
},
186+
})
177187

178-
coreInstance.rawLayerList.initializeLayerList(
179-
services,
180-
async (layerConf) => {
181-
const client = await coreInstance.createMap({
182-
containerId,
183-
mapConfiguration: {
184-
...mapConfiguration,
185-
layerConf: modifyLayerConfiguration(layerConf),
186-
},
187-
})
188+
resolve(client)
189+
}
190+
)
191+
})
188192

189-
resolve(client)
190-
}
191-
)
192-
}),
193+
export default {
194+
createMap,
193195
}

pages/examples/render.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import client from '../node_modules/@polar/client-generic/dist/polar-client.js'
1+
import { createMap } from '../node_modules/@polar/client-generic/dist/polar-client.js'
22

33
const commonParameters = {
44
services: 'https://geodienste.hamburg.de/services-internet.json',
@@ -24,7 +24,7 @@ ${(typeof description === 'string' ? [description] : description)
2424
<summary>View configuration</summary>
2525
<pre>
2626
<code>
27-
client.createMap(${JSON.stringify(parameterObject, null, 2)})
27+
createMap(${JSON.stringify(parameterObject, null, 2)})
2828
</code>
2929
</pre>
3030
</details>
@@ -80,7 +80,7 @@ export default ({
8080

8181
document.getElementById('render-node').appendChild(card)
8282

83-
client.createMap(parameterObject).then((mapClient) => {
83+
createMap(parameterObject).then((mapClient) => {
8484
if (postCreation) {
8585
postCreation({ mapClient, id })
8686
}

0 commit comments

Comments
 (0)