export type GetApiV1StaticArgs = {key?: string | undefined, center?: string | undefined, zoom?: number | undefined, width?: number | undefined, height?: number | undefined, markers?: string | undefined}; export type GetApiV1StaticOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Static map * * GET /v1/static * * Also accepts auth: ApiKeyQuery */ export const getApiV1Static = async (args: GetApiV1StaticArgs, options?: GetApiV1StaticOptions) => { const {baseUrl = "https://api.latlng.work", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.key != null) query.append("key", String(args.key)) if (args.center != null) query.append("center", String(args.center)) if (args.zoom != null) query.append("zoom", String(args.zoom)) if (args.width != null) query.append("width", String(args.width)) if (args.height != null) query.append("height", String(args.height)) if (args.markers != null) query.append("markers", String(args.markers)) if (ApiKeyAuth !== undefined) headers.set("X-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/static${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() };