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

import _default, * as esriLoader from 'esri-loader';
import { getShgcListForMap } from '../../../../api/zhxxAPI.js';
export function getRyXzcList(mapObject, userId, currentAdCode) {
  esriLoader
    .loadModules(
      [
        'esri/Graphic',
        'esri/geometry/Point',
        'esri/geometry/SpatialReference',
        'dojo/domReady!',
      ],
      options,
    )
    .then(([Graphic, Point, SpatialReference]) => {
      var xzcGraphicLayer = mapObject.findLayerById('xzcGraphicLayer');
      xzcGraphicLayer.removeAll();
      var symbol = {
        type: 'picture-marker',
        url: '/src/views/zongHeXinXiNew/assets/xzc.png',
        width: '18px',
        height: '21px',
      };
      var gra, pt, symbol;
      getShgcListForMap(userId, '2', currentAdCode).then((res) => {
        if (res.data) {
          res.data.forEach((item) => {
            if (item.lttdPc && item.lgtdPc) {
              pt = new Point(
                item.lgtdPc,
                item.lttdPc,
                new SpatialReference(4326),
              );
              gra = new Graphic({
                geometry: pt,
                symbol: symbol,
                attributes: item,
              });
              xzcGraphicLayer.add(gra);
            }
          });
        }
      });
    })
    .catch((err) => {
      console.error(err);
    });
}
