export type GetApiMapsMapIdStaticMinxMinyMaxxMaxyWidthXHeightScaleFormatOptions = {baseUrl?: string | undefined, key?: string | undefined, fetch?: typeof fetch | undefined}; /** * Bounds-based image * * GET /maps/{mapId}/static/{minx},{miny},{maxx},{maxy}/{width}x{height}{scale}.{format} */ export const getApiMapsMapIdStaticMinxMinyMaxxMaxyWidthXHeightScaleFormat = async (options?: GetApiMapsMapIdStaticMinxMinyMaxxMaxyWidthXHeightScaleFormatOptions) => { const {baseUrl = "https://api.maptiler.com", fetch: fetchFn = fetch, key} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (key !== undefined) query.set("key", key) const url = `${baseUrl.replace(/\/+$/, '')}/maps/${encodeURIComponent(String(args.mapId))}/static/${encodeURIComponent(String(args.minx))},${encodeURIComponent(String(args.miny))},${encodeURIComponent(String(args.maxx))},${encodeURIComponent(String(args.maxy))}/${encodeURIComponent(String(args.width))}x${encodeURIComponent(String(args.height))}${encodeURIComponent(String(args.scale))}.${encodeURIComponent(String(args.format))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };