Skip to content

Commit

Permalink
Merge pull request #188 from Dataport/feature/direct-export
Browse files Browse the repository at this point in the history
Additionally expose createMap for @polar/client-generic
  • Loading branch information
dopenguin authored Sep 26, 2024
2 parents ee74abb + 784d9e8 commit 896f418
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 34 deletions.
4 changes: 4 additions & 0 deletions packages/clients/generic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## unpublished

- Feature: Directly expose `createMap` to be able to import it directly when using this client.

## 1.0.0

Initial release.
64 changes: 33 additions & 31 deletions packages/clients/generic/src/polar-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,38 +156,40 @@ const addPlugins = (coreInstance: PolarCore, enabledPlugins: PluginName[]) => {
)
}

export default {
createMap: ({
containerId,
services,
mapConfiguration,
enabledPlugins = [],
modifyLayerConfiguration = (x) => x,
}: {
containerId: string
services: object[]
mapConfiguration: MapConfig
enabledPlugins: Array<PluginName>
modifyLayerConfiguration: (layerConf: object[]) => object[]
}) =>
new Promise((resolve) => {
const coreInstance = { ...core }
export const createMap = ({
containerId,
services,
mapConfiguration,
enabledPlugins = [],
modifyLayerConfiguration = (x) => x,
}: {
containerId: string
services: object[]
mapConfiguration: MapConfig
enabledPlugins: Array<PluginName>
modifyLayerConfiguration: (layerConf: object[]) => object[]
}) =>
new Promise((resolve) => {
const coreInstance = { ...core }

addPlugins(coreInstance, enabledPlugins)

addPlugins(coreInstance, enabledPlugins)
coreInstance.rawLayerList.initializeLayerList(
services,
async (layerConf) => {
const client = await coreInstance.createMap({
containerId,
mapConfiguration: {
...mapConfiguration,
layerConf: modifyLayerConfiguration(layerConf),
},
})

coreInstance.rawLayerList.initializeLayerList(
services,
async (layerConf) => {
const client = await coreInstance.createMap({
containerId,
mapConfiguration: {
...mapConfiguration,
layerConf: modifyLayerConfiguration(layerConf),
},
})
resolve(client)
}
)
})

resolve(client)
}
)
}),
export default {
createMap,
}
6 changes: 3 additions & 3 deletions pages/examples/render.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import client from '../node_modules/@polar/client-generic/dist/polar-client.js'
import { createMap } from '../node_modules/@polar/client-generic/dist/polar-client.js'

const commonParameters = {
services: 'https://geodienste.hamburg.de/services-internet.json',
Expand All @@ -24,7 +24,7 @@ ${(typeof description === 'string' ? [description] : description)
<summary>View configuration</summary>
<pre>
<code>
client.createMap(${JSON.stringify(parameterObject, null, 2)})
createMap(${JSON.stringify(parameterObject, null, 2)})
</code>
</pre>
</details>
Expand Down Expand Up @@ -80,7 +80,7 @@ export default ({

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

client.createMap(parameterObject).then((mapClient) => {
createMap(parameterObject).then((mapClient) => {
if (postCreation) {
postCreation({ mapClient, id })
}
Expand Down

0 comments on commit 896f418

Please sign in to comment.