使用门户底图

尝试一下在线预览

您可以在 GeoScene API 中使用 Portal 为 JavaScript 应用程序创建 Basemaps。这样做时,您可以利用您的组织的默认底图默认矢量底图。您可以在 geosceneConfig 中定义 portalUrlBasemapGallery 微件将使用该门户中配置的底图。

1. 初始化门户实例

  
1
2
// 默认为 arcgis.com 的门户
const portal = new Portal();

2. 加载门户资源

                                     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// 如果您在 geosceneConfig 中定义门户 URL,
// 则 BasemapGallery 微件可以确定
// 要使用的底图。
geosceneConfig.portalUrl = "https://jsapi.maps.arcgis.com";
// 初始化一个门户实例并加载它
const portal = new Portal();
portal
  .load()
  .then(() => {
    // 可以将门户配置为
    // 默认使用或不使用矢量底图。
    const basemap = portal.useVectorBasemaps ?
          portal.defaultVectorBasemap : portal.defaultBasemap;
    const map = new Map({
      basemap: basemap
    });
    const view = new MapView({
      container: "viewDiv",
      map: map,
      center: [-118.24, 34.073],
      scale: 10000
    });
    // BasemapGallery 将使用 geosceneConfig.portalUrl 中定义的
    // Portal URL 配置的底图
    const basemapGallery = new BasemapGallery({
      view: view
    });
    const bgExpand = new Expand({
      view: view,
      content: basemapGallery
    });
    view.ui.add(bgExpand, "top-right");
  })
  .catch((error) => {
    console.warn(error);
  });
});

这允许您使用您的组织设置在您的组织中创建一致的应用程序。

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.