1
2
3
4
5
6
// Initialize the WebMap and pass in the webmap idconst webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()id: "471eb0bf37074b1fbb972b1da70fb310"// webmap id }
});
初始化 web 地图时,用户需要将 URL 设置为托管 web 地图的门户。默认门户 URL 为 "https://www.geoscene.cn"。为此,需要导入 geoscene/config 类,并设置其 portalUrl 集。以下代码段阐释了此工作流。
Use dark colors for code blocks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require([
"geoscene/WebMap",
"geoscene/views/MapView",
"geoscene/widgets/UtilityNetworkTrace",
"geoscene/config"], (WebMap, MapView, UtilityNetworkTrace, geosceneConfig) => {
// Set the hostname to the on-premise portal geosceneConfig.portalUrl = "https://myHostName.domainName.com/webadaptorName";
const webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()id: "471eb0bf37074b1fbb972b1da70fb310"// webmap id }
});
...
});
加载 WebMap 后,可以初始化微件并将其添加到视图中。
Use dark colors for code blocks
1
2
3
4
5
6
7
// Initialize the UtilityNetworkTrace widgetconst utilityNetworkTrace = new UtilityNetworkTrace({
view: view
});
// Add the widget to the viewview.ui.add(utilityNetworkTrace, "top-right");