-
Notifications
You must be signed in to change notification settings - Fork 0
/
unfoldedMap.js
39 lines (36 loc) · 956 Bytes
/
unfoldedMap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {
UnfoldedMap
} from '@unfolded/map-sdk';
import * as config from './config';
// map settings
const mapTheme = 'light_streets'; // default map theme
/**
* Creates new map instance.
* @param {*} geoData GeoJSON data to display on the map.
* @param {*} mapContainer Map view container.
* @returns map instance to display.
*/
export function createMap(geoData, mapContainer) {
let map;
try {
console.log('unfolded.map:createMap(): creating map ...');
map = new UnfoldedMap({
embed: false,
appendToDocument: false,
height: config.mapHeight,
onLoad: () => {
map.addDataset({
uuid: 'geojson data',
label: 'Geo Data',
data: JSON.stringify(geoData)
});
console.log('unfolded.map:createMap(): map loaded!');
}
});
}
catch (error) {
console.error('unfolded.map:createMap(): Error:\n', error);
}
map.render(mapContainer);
return map;
}