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

import _default, * as esriLoader from 'esri-loader';
import { getShgcListForMap } from '../../../../api/zhxxAPI.js';
export function getCountry150List(mapObject, userId, currentAdCode) {
  esriLoader
    .loadModules(
      [
        'esri/Graphic',
        'esri/geometry/Point',
        'esri/geometry/SpatialReference',
        'dojo/domReady!',
      ],
      options,
    )
    .then(([Graphic, Point, SpatialReference]) => {
      var country150Layer = mapObject.findLayerById('country150Layer');
      country150Layer.removeAll();
      var symbol = {
        type: 'picture-marker',
        url: '/src/views/zongHeXinXiNew/assets/xian.png',
        width: '18px',
        height: '21px',
      };
      var gra, pt, symbol;
      getShgcListForMap(userId, '23', currentAdCode).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,
              });
              country150Layer.add(gra);
            }
          });
        }
      });
    })
    .catch((err) => {
      console.error(err);
    });
}
