Select to view content in your preferred language

Making a map floor aware using JavaScript

455
1
02-06-2024 05:24 AM
AbhyanshuGupta
New Contributor III

Hi, I am creating a custom space planner application in which i am using a map which is not floor aware. I am making the map floor aware through code for which i am writing the following code:
webMap.current?.loadAll().then(() => {
const levelLayer = webMap.current?.allLayers?.find(
(x) => x.title === "Levels"
);
const facilityLayer = webMap.current?.allLayers?.find(
(x) => x.title === "Facilities"
);
const floorInfoLayer = new LayerFloorInfo({
floorField: "LEVEL_ID",
});
console.log(webMap.current.allLayers);
webMap.current?.allLayers?.forEach((x) => {
if(x.title === "Units" || x.title === "Details"||x.title=== "Units Base"){
x.floorInfo = floorInfoLayer;
}
});

const floorInfoWebMap = {
levelLayer: {
facilityIdField: "FACILITY_ID",
layerId: levelLayer.id,
levelIdField: "LEVEL_ID",
levelNumberField: "LEVEL_NUMBER",
longNameField: "NAME",
shortNameField: "NAME_SHORT",
verticalOrderField: "VERTICAL_ORDER",
},
facilityLayer: {
facilityIdField: "FACILITY_ID",
layerId: facilityLayer.id,
nameField: "NAME",
siteIdField: "SITE_ID",
},
};
webMap.current.floorInfo = floorInfoWebMap;
});
When i am running the code it is making one map floor aware but for the other map i am not being able to make my map floor aware. Can someone please suggest me what am i doing wrong and how to resolve the issue? The difference in the two map is that second map which is failing to become flooraware has an additional 'Occupants' and a 'Units Base' layers

0 Kudos
1 Reply
AbhyanshuGupta
New Contributor III

Can someone please suggest.

0 Kudos