const options = {
  url: '/arcgisApi/4.7/init.js',
};

import _default, * as esriLoader from 'esri-loader';
import { getFuPinXianList } from '../../../api/zhxxAPI.js';
export function getFupinxianList(_self) {
  esriLoader
    .loadModules(
      [
        'esri/Graphic',
        'esri/geometry/Point',
        'esri/geometry/SpatialReference',
        'dojo/domReady!',
      ],
      options,
    )
    .then(([Graphic, Point, SpatialReference]) => {
      var graphicLayerFpx = _self.mapObject.findLayerById('graphicLayerFpx');
      graphicLayerFpx.removeAll();
      var symbol = {
        type: 'picture-marker',
        url: '/src/views/zongHeXinXiNew/assets/online.png',
        width: '18px',
        height: '21px',
      };
      var gra, pt;
      var obj = {
        code: _self.currentAdCode,
        zdx: '', //重点县
        bjx: '', //边境县
        tcx: '', //天窗县
        ddfp: '', //定点扶贫县
      };
      getFuPinXianList(obj).then((res) => {
        if (res.data) {
          res.data.forEach((item) => {
            if (item.lttd && item.lgtd) {
              pt = new Point(item.lgtd, item.lttd, new SpatialReference(4326));
              gra = new Graphic({
                geometry: pt,
                symbol: symbol,
                attributes: item,
              });
              graphicLayerFpx.add(gra);
            }
          });
        }
      });
    })
    .catch((err) => {
      console.error(err);
    });
}
