import WebGLTile from "ol/layer/WebGLTile";
import GeoTIFF from "ol/source/GeoTIFF";
export function removeWebGLTile(name) {
  // console.log(name);
  const allLayers = window.map[name].getLayers().getArray();
  allLayers.forEach((layer) => {
    if (layer instanceof WebGLTile) {
      window.map[name].removeLayer(layer);
    }
  });
  // console.log(window.map[name].getLayers().getArray(), name);
}
export function addTiff(name, url) {
  const source = new GeoTIFF({
    sources: [
      {
        url,
        nodata: 0,
        imageExtent: [38.207187, 106.672957, 38.21268, 106.67845],
        projection: "EPSG:4326",
      },
    ],
  });
  const layer = new WebGLTile({
    source: source,
  });
  window.map[name].addLayer(layer);
}