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

2 lines (1 loc) 3.49 kB
import*as e from"ramda";import{orphanTest as t}from"../plugins/wayfinder/src/navGraphDebug.js";import{ad as n,$ as s,$$ as o,del as a}from"./utils/dom.js";import{singleFile as r}from"./utils/funcs.js";"undefined"!=typeof window&&(window.R=e);const i=(e,t)=>d((()=>t.send(e)),t),d=(e,t)=>{const n=t.monitor("homeview/performSearch",(({term:t})=>{t||(e(),n())}))};async function u(){const e=await this.bus.get("map/getPadding"),t=(e.left-e.right)/2,o=(e.top-e.bottom)/2,r=n({html:'<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><path stroke="#fF000080" stroke-width="2" d="M0 50h45M55 50h45M50 0v45M50 55v45"/></svg>',styles:{position:"absolute",left:"50%",top:"50%","margin-left":-50+t+"px","margin-top":-50+o+"px"}},s(".maplibregl-map"));d((()=>a(r)),this.bus)}var g={bounds:async function(){const e=await this.bus.get("venueData/getVenueCenter"),{venueRadius:t,bounds:n}=await this.bus.get("venueData/getVenueData");this.bus.send("map/showVenueBounds",{venueCenter:e,venueRadius:t,bounds:n}),i("map/resetVenueBounds",this.bus)},buildingBounds:async function(e){this.bus.send("map/showBuildingBounds",{nameFilter:e}),i("map/resetVenueBounds",this.bus),u.apply(this)},dndGo:function(){const e=this.bus,t=(e,t)=>{e.preventDefault(),t?e.target.classList.add("dragover"):e.target.classList.remove("dragover")},n={drop:async function(n){t(n,!1);for(const t of n.dataTransfer.files){const n=t.name;if("application/json"===t.type||t.type.startsWith("text/")){const s=new FileReader;s.onload=r((async s=>e.send("debugTools/fileDrop",{file:t,filename:n,content:s.target.result}))),s.readAsText(t)}}},dragover:function(e){t(e,!0)},dragleave:function(e){t(e,!1)}};Object.keys(n).forEach((function(e){document.body.addEventListener(e,n[e])})),console.log("DnD Listeners installed")},floorBounds:async function(e){const t=this.bus;t.send("map/showFloorBounds",{nameFilter:e}),i("map/resetVenueBounds",t);const n=t.monitor("map/floorChanged",(()=>t.send("map/showFloorBounds",{nameFilter:e})));d(n,t),u.apply(this)},getPoiById:function(e){return this.bus.send("poi/getById",{id:e}).then((e=>e[0]))},highlightNodes:()=>n({tag:"style",html:"* { background-color: rgba(255,0,0,.2); } * * { background-color: rgba(0,255,0,.2); } * * * { background-color: rgba(0,0,255,.2); } * * * * { background-color: rgba(255,0,255,.2); } * * * * * { background-color: rgba(0,255,255,.2); } * * * * * * { background-color: rgba(255,255,0,.2); } * * * * * * * { background-color: rgba(255,0,0,.2); } * * * * * * * * { background-color: rgba(0,255,0,.2); } * * * * * * * * * { background-color: rgba(0,0,255,.2); }"},s("head")),orphanTest:t,padding:async function(){this.bus.send("map/togglePadding"),i("map/togglePadding",this.bus)},poisByCategory:function(){return this.bus.send("poi/getAll").then((e=>e[0])).then((e=>Object.values(e))).then(e.groupBy((e=>e.category)))},showCenter:u,showgraph:async function(){const e=await this.bus.get("wayfinder/getNavGraphFeatures");this.bus.send("map/showNavGraphFeatures",{navGraph:e}),i("map/resetNavGraphFeatures",this.bus)},showIcons:()=>{s("#mapRenderDiv").innerHTML="<style> div { display: inline-block; text-align: center; border: 1px solid lightblue; }</style>"+o("svg symbol").map((e=>`<div><svg><use xlink:href="#${e.id}"/></svg><br/>${e.id}</div>`)).join("")},showOrphaned:async function(){const e=await this.bus.get("wayfinder/_getNavGraph"),n=t(e._nodes);this.bus.send("map/showOrphanedGraphNodes",{orphanedNodes:n.orphaned})}};export{g as default};