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

62 lines (56 loc) 2.18 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'], // handoff indicator (used in analytics) home: 'online/homeView', // doing a handoff to home view zoom: 'mapRenderer', pitch: 'mapRenderer', bearing: 'mapRenderer', lat: 'mapRenderer', lng: 'mapRenderer', radius: 'mapRenderer', buildingId: 'mapRenderer', floorId: 'mapRenderer', visualTest: 'mapRenderer', refInstallId: 'analytics2' }; // Note: see note about security for forceCreate on postproc-stateTracking - same thing // applies here! function setDeepLinksForParms (config, parms, forceCreate) { // allow for lldebug on the URL to set debug mode. I made it "lldebug" just so it wasn't SO easy to guess. ;-) if (parms.has('lldebug')) { try { config.debug = JSON.parse(parms.get('lldebug')); if (config.debug === null) // allow for a URL parm of just `lldebug` (no value = null) config.debug = { }; } catch (e) { config.debug = true; } } Object.keys(parmToPlugin) .forEach(key => { if (parms.has(key)) { let plugins = parmToPlugin[key]; if (!Array.isArray(plugins)) plugins = [plugins]; plugins.forEach(plugin => { let pc = config.plugins[plugin]; // config for this plugin if (!pc && forceCreate) pc = config.plugins[plugin] = { }; pc.deepLinkProps = { ...pc.deepLinkProps, [key]: parms.get(key) }; }); } }); if (parms.has('poiId') && parms.has('showNav')) // poiId doubles as a parm for both - if showNav is defined, it should target getDirectionsFromTo only delete config.plugins['online/poiView'].deepLinkProps.poiId; return config } exports.setDeepLinksForParms = setDeepLinksForParms;