我们知道,IE严重拖了前端发展的后腿,而我们的很多客户只会用IE不知道有啥FF,Chrome。那么先进的ES6等就不能在这些宿主上运行了,对应的就出现了,babel和各种各样的loader。同样,arcgis for javascript api不能在没有dojo的环境中加载,因此为了加载这些api,esri为我们提供相应的loader,这里使用的是webpack,那么就需要esri-loader。
Loading Modules from the ArcGIS API for JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// first, we use Dojo's loader to require the map class esriLoader.loadModules(['esri/views/MapView', 'esri/WebMap']) .then(([MapView, WebMap]) => { // then we load a web map from an id var webmap = new WebMap({ portalItem: { // autocasts as new PortalItem() id: 'f2e9b762544945f390ca4ac3671cfa72' } }); // and we show that map in a container w/ id #viewDiv var view = new MapView({ map: webmap, container: 'viewDiv' }); }) .catch(err => { // handle any errors console.error(err); });