主题
公共设施网络简介
字数统计: 359 字
阅读时长: 约 1 分钟
当前版本: 4.29
GeoScene Maps SDK for JavaScript支持在应用程序中显示公共设施网络、查看关联和配置追踪。

加载 WebMap
加载一个包含有公共设施网络图层的 WebMap 就会开启公共设施网络功能。以下代码片段演示了如何加载GeoScene Enterprise上托管的 web 地图。
js
require([
"geoscene/WebMap",
"geoscene/views/MapView",
"geoscene/config"
], (WebMap, MapView, geosceneConfig) => {
// set the hostname to the portal instance
geosceneConfig.portalUrl = "https://myHostName.domain.com/geoscene";
// initialize the WebMap with the webmap id
const webMap = new WebMap({
portalItem: {
id: "MyWebmapId"
}
});
const view = new MapView({
map: webMap
});
});
加载公共设施网络
必须先完成 WebMap 加载,然后才能使用 WebMap.utilityNetworks 属性访问公共设施网络。 通过utilityNetworks对象的load() 方法访问公共设施网络及其属性。
js
webMap.when(async () => {
// check if webMap contains utility networks
if (webMap.utilityNetworks.length > 0) {
// assign the utility network at index 0
utilityNetwork = webMap.utilityNetworks.getItemAt(0);
// trigger the loading of the UtilityNetwork instance
await utilityNetwork.load();
}
});