Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the Building Explorer tool to the library #576

Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 99 additions & 1 deletion src/functionality/esriWidgetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,33 @@
import { when } from "esri/core/reactiveUtils";
import BasemapToggle from "esri/widgets/BasemapToggle";
import Bookmarks from "esri/widgets/Bookmarks";
import BuildingExplorer from "esri/widgets/BuildingExplorer";
Fixed Show fixed Hide fixed
import Compass from "esri/widgets/Compass";
import Daylight from "esri/widgets/Daylight";
Fixed Show fixed Hide fixed
import Expand from "esri/widgets/Expand";
import FloorFilter from "esri/widgets/FloorFilter";
import FullScreen from "esri/widgets/Fullscreen";
import Home from "esri/widgets/Home";
import LayerList from "esri/widgets/LayerList";
import Legend from "esri/widgets/Legend";
import LineOfSight from "esri/widgets/LineOfSight";
Fixed Show fixed Hide fixed
import Locate from "esri/widgets/Locate";
import Scalebar from "esri/widgets/ScaleBar";
import ShadowCast from "esri/widgets/ShadowCast";
Fixed Show fixed Hide fixed
import Slice from "esri/widgets/Slice";
Fixed Show fixed Hide fixed
import Viewpoint from "esri/Viewpoint";
import Viewshed from "esri/analysis/Viewshed";
Fixed Show fixed Hide fixed
import Weather from "esri/widgets/Weather";
Fixed Show fixed Hide fixed
import Zoom from "esri/widgets/Zoom";

import { autoUpdatedStrings } from "../structuralFunctionality/t9nUtils";
const bundleName = "dist/assets/t9n/common";

import { getBasemaps, resetBasemapsInToggle } from "./basemapToggle";
import { checkForElement } from "./generalUtils";
import { createSearch, handleSearchExtent } from "./search";
import ApplicationBase from "../baseClasses/ApplicationBase";
import { ApplicationConfig } from "../interfaces/applicationBase";
import { ApplicationConfig, esriWidgetProps } from "../interfaces/applicationBase";
Fixed Show fixed Hide fixed

/**
* Watch for changes in home, homePosition, mapArea, mapAreaConfig
Expand Down Expand Up @@ -820,3 +830,91 @@
configureListItemPanelLegend(item, layerListLegend);
});
}

function _findNode(className: string): HTMLElement {
const mainNodes = document.getElementsByClassName(className);
let node = null;
for (let j = 0; j < mainNodes.length; j++) {
node = mainNodes[j] as HTMLElement;
}
return node ? node : null;
}

export async function addBuildingExplorer(props: {
config: ApplicationConfig;
view?: __esri.SceneView;
portal?: __esri.Portal;
propertyName?: string;
telemetry?: any;
}): Promise<void> {
const { view, config, propertyName } = props;
const { buildingExplorer, buildingExplorerPosition, appBundle } = config;
const BuildingExplorer = await import("esri/widgets/BuildingExplorer");
if (!BuildingExplorer) return;

const node = view.ui.find("buildingExplorerExpand") as __esri.Expand;

if (!buildingExplorer) {
if (node) view.ui.remove(node);
return;
}
const group = getPosition(buildingExplorerPosition);

// move the node if it exists
if (propertyName === "buildingExplorerPosition" && node) {
node.group = group;
} else if (propertyName === "buildingExplorer") {
if (node || _findNode("esri-building-explorer")) return;
const buildingLayers = [];
view.map.layers?.filter((l) => {
if (l?.type === "group") {
return (l as __esri.GroupLayer)?.layers?.some((subLayer) => {
if (subLayer?.type === "building-scene") {
buildingLayers.push(subLayer);
}
});
} else {
if (l?.type === "building-scene") {
buildingLayers.push(l);
}
}
});
const buildingExplorerWidget = new BuildingExplorer.default({ view, layers: buildingLayers });
const tip = appBundle.tools.buildingExplorer;
const expand = new Expand({
id: "buildingExplorerExpand",
view,
mode: "auto",
group,
collapseTooltip: tip,
expandTooltip: tip,
content: buildingExplorerWidget
});

view.ui.add(expand, buildingExplorerPosition);
autoUpdatedStrings.add({
obj: expand,
property: "collapseTooltip",
bundleName: bundleName,
key: "tools.buildingExplorer"
});
autoUpdatedStrings.add({
obj: expand,
property: "expandTooltip",
bundleName: bundleName,
key: "tools.buildingExplorer"
});
}
}

export function addDaylight(): void { console.info("Daylight"); }

export function addLineOfSight(): void { console.info("Line of Sight"); }

export function addShadowCast(): void { console.info("Shadow Cast"); }

export function addSlice(): void { console.info("Slice"); }

export function addViewshed(): void { console.info("Viewshed"); }

export function addWeather(): void { console.info("Weather"); }
Loading