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
      })
    })
}

posted on 2023-08-30 15:04  Just丶随心  阅读(251)  评论(0编辑  收藏  举报

导航