UNPKG

atriusmaps-node-sdk

Version:

This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information

66 lines (63 loc) 1.95 kB
'use strict'; const parmToPlugin = { navFrom: "online/getDirectionsFromTo", navTo: "online/getDirectionsFromTo", waypoints: "online/getDirectionsFromTo", accessible: "online/getDirectionsFromTo", showNav: "online/getDirectionsFromTo", poiId: ["online/getDirectionsFromTo", "online/poiView"], vid: "venueDataLoader", stage: "venueDataLoader", contentStage: "venueDataLoader", accountId: "venueDataLoader", search: "online/headerOnline", ho: ["online/getDirectionsFromTo", "analytics2"], home: "online/homeView", zoom: "mapRenderer", pitch: "mapRenderer", bearing: "mapRenderer", lat: "mapRenderer", lng: "mapRenderer", radius: "mapRenderer", buildingId: "mapRenderer", floorId: "mapRenderer", visualTest: "mapRenderer", refInstallId: "analytics2", disableZoomToExplorePopup: "levelIndicator" }; function setDeepLinksForParms(config, parms, forceCreate = false) { if (parms.has("lldebug")) { try { const parsedDebug = JSON.parse(parms.get("lldebug") ?? "null"); if (parsedDebug === null) { config.debug = {}; } else { config.debug = parsedDebug; } } catch { config.debug = true; } } Object.keys(parmToPlugin).forEach((key) => { if (!parms.has(key)) { return; } const pluginNames = parmToPlugin[key]; const plugins = Array.isArray(pluginNames) ? pluginNames : [pluginNames]; plugins.forEach((plugin) => { let pluginConfig = config.plugins[plugin]; if (!pluginConfig && forceCreate) { pluginConfig = config.plugins[plugin] = {}; } if (!pluginConfig) { return; } pluginConfig.deepLinkProps = { ...pluginConfig.deepLinkProps, [key]: parms.get(key) }; }); }); if (parms.has("poiId") && parms.has("showNav")) { delete config.plugins["online/poiView"]?.deepLinkProps?.poiId; } return config; } exports.setDeepLinksForParms = setDeepLinksForParms;