esri-loader
npm i esri-loader
import { loadScript, loadCss } from 'esri-loader'
// 添加gis的样式和api
loadCss("http://自己的地址/library/4.14/esri/css/main.css");
loadScript({
dojoConfig: {
async: true
},
url: 'http://自己的地址/library/4.14/init.js'
});
import { loadModules } from 'esri-loader'
export function loadFeatureLayer(title, url, visible = true) {
return loadModules(['esri/layers/FeatureLayer'], { css: true })
.then(([FeatureLayer]) => {
return FeatureLayer({
title: title,
outFields: ['*'],
url: url,
featureReduction: { type: 'selection' },
visible: visible
})
})
}