import { attachImageToMap } from "./attach-image-to-map.js";
import { createBitmapConfigOptions } from "./create-bitmap-config-options.js";
import { getDataUri } from "./get-data-uri.js";
import { DEFAULT_INPUT_ICON_SIZE } from "../constants.js";
import { getShape } from "../shapes/shape-picker.js";
const attachImageFromShape = (map, shape, name, outputSize) => {
  const pickedShape = getShape(shape);
  const stringUrl = getDataUri(encodeURIComponent(pickedShape));
  const img = new Image(DEFAULT_INPUT_ICON_SIZE, DEFAULT_INPUT_ICON_SIZE);
  img.addEventListener("load", () => {
    createImageBitmap(
      img,
      0,
      0,
      DEFAULT_INPUT_ICON_SIZE,
      DEFAULT_INPUT_ICON_SIZE,
      createBitmapConfigOptions(outputSize)
    ).then((bitmap) => {
      attachImageToMap(map, bitmap, name);
    });
  });
  img.src = stringUrl;
};
export {
  attachImageFromShape
};
//# sourceMappingURL=attach-image-from-shape.js.map
