【发布时间】:2021-12-25 00:09:57
【问题描述】:
我正在使用 ArcGIS Javascript API 4.20 从 ArcGIS Online 中检索网络地图,并且我可以使用以下简单脚本通过提供其 ID 来加载和显示它:
import MapView from "https://js.arcgis.com/4.20/@arcgis/core/views/MapView.js";
import WebMap from "https://js.arcgis.com/4.20/@arcgis/core/WebMap.js";
import esriId from "https://js.arcgis.com/4.20/@arcgis/core/identity/IdentityManager.js";
var webmap = new WebMap({
portalItem: {
id: "1234567890qwertyuiop"
}
});
var view = new MapView({
map: webmap,
container: "mapFrame", //ID of the HTML element where the map will be displayed
});
我需要找到一种方法,以便在地图加载时以编程方式调整地图的缩放比例,以便其中包含的每个图层/要素在地图中显示的区域中都可见。
我找到了使用“fullExtent”函数的示例和参考资料,但据我了解,这旨在与图层一起使用。我无法弄清楚如何将相同的想法应用于完整的网络地图并使其发挥作用: https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fullExtent
webmap.when(function(){
view.extent = webmap.fullExtent;
});
//I've tried using this. It doesn't raise any errors, but does nothing.
你能告诉我我做错了什么吗?或者分享任何想法以使用不同的方法以编程方式实现我的需求?
【问题讨论】:
标签: javascript arcgis arcgis-js-api arcgis-online