点击地图点位弹窗无法弹出,控制台报错:d.ActionsCollection is not a constructor
问题:点击地图点位弹窗无法弹出,控制台报ActionsCollection构造函数错误
点击地图上的点位时,弹窗无法正常弹出,控制台输出错误信息:
Popup.js:6 Uncaught (in promise) TypeError: d.ActionsCollection is not a constructor
相关代码
require(["esri/WebMap", "esri/views/MapView", "esri/widgets/Search", "esri/widgets/Zoom", "esri/widgets/Locate", "esri/popup/content/ImageMediaInfo", "esri/config", "esri/portal/Portal"], function (WebMap, MapView, Search, Zoom, Locate, ImageMediaInfo, esriConfig, Portal) { esriConfig.portalUrl = "https://test.org/portal"; webmap = new WebMap({ portalItem: { id: "*********", }, }); var view = new MapView({ map: webmap, container: "viewDiv", center: [-95.9406, 41.26], zoom: 13, basemap: "topo", constraints: { minZoom: 12, }, }); // webmap.loadStatus view.when(function () { webmap .load() .then(function () { return webmap.basemap.load(); }) .then(function () { let allLayers = webmap.allLayers; var promises = allLayers.map(function (layer) { return layer.load(); }); return Promise.all(promises.toArray()); }) .then(function (layers) { webmap.removeAll(); }) .catch(function (error) { // the webmap or portal failed to load console.log("The resource failed to load: ", error); }); }); });
解决方案
- 补充缺失的模块依赖:错误提示
ActionsCollection未定义,说明代码未加载对应的ArcGIS模块。如果WebMap配置了弹窗操作,需在require的依赖列表中添加esri/popup/actions/ActionCollection(旧版API)或esri/core/Collection(新版API),并在回调函数中引入对应的构造函数。 - 移除图层删除逻辑:代码中
webmap.removeAll()会清空WebMap内所有图层,导致没有可触发弹窗的点位图层。若这不是预期操作,直接删除该行代码。 - 核对API版本兼容性:ArcGIS JS API 4.x部分新版本已弃用
ActionsCollection,改用Collection管理弹窗操作。需确认API版本与WebMap的弹窗配置匹配,若版本不兼容,需调整模块引用或更新WebMap配置。
内容的提问来源于stack exchange,提问作者Adam-KER
相关产品推荐
相关产品推荐

