Skip to content

Commit

Permalink
Add mapState as parameter (origo-map#1717)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokd authored Mar 22, 2023
1 parent b8053b3 commit 08e6ba4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/loadresources.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import permalink from './permalink/permalink';
import permalinkParser from './permalink/permalinkparser';
import getUrl from './utils/geturl';
import isUrl from './utils/isurl';
import trimUrl from './utils/trimurl';
Expand Down Expand Up @@ -142,6 +143,16 @@ const loadResources = async function loadResources(mapOptions, config) {
map.options.map = json;
map.options.params = urlParams;

if (config.mapState) {
const mapObj = {};
const state = config.mapState;
Object.keys(state).forEach(key => {
if (permalinkParser[key]) mapObj[key] = permalinkParser[key](state[key]);
else mapObj[key] = state[key];
});
map.options.params = mapObj;
}

for (let i = 0; i < map.options.controls.length; i += 1) {
if (map.options.controls[i].name === 'sharemap') {
if (map.options.controls[i].options) {
Expand Down

0 comments on commit 08e6ba4

Please sign in to comment.