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

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