import {
  GEOSERVER_URL,
  WORKSPACE,
} from '@/pages/Slave/SGW/Map/config/MapConfig';
import ImageLayer from 'ol/layer/Image';
import { ImageWMS } from 'ol/source';

/**
 * Tạo một WMS tile layer.
 */
export function createWmsLayer(layerName: string) {
  // return new TileLayer({
  //   visible: true,
  //   source: new TileWMS({
  //     url: `${GEOSERVER_URL}/${WORKSPACE}/wms`,
  //     params: {
  //       LAYERS: `${WORKSPACE}:${layerName}`,
  //       TILED: true,
  //       FORMAT: "image/png",
  //       TRANSPARENT: true,
  //     },
  //     serverType: "geoserver",
  //     crossOrigin: "anonymous",
  //   }),
  //   ...options,
  // });
  return new ImageLayer({
    source: new ImageWMS({
      url: `${GEOSERVER_URL}/${WORKSPACE}/wms`,
      params: { LAYERS: `${WORKSPACE}:${layerName}` },
    }),
  });
}
