0

Returns PNG weather map for given area and variable

by
Published Oct 17, 2025

## PNG weather forecast maps for given area and variable ### Area specification There are two ways to specify geographical area you need for your map: 1.

Script meteosource Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Returns PNG weather map for given area and variable
4
 * ## PNG weather forecast maps for given area and variable
5

6
### Area specification
7
There are two ways to specify geographical area you need for your map:
8
1.
9
 */
10
export async function main(
11
	auth: RT.Meteosource,
12
	variable: string | undefined,
13
	datetime: string | undefined,
14
	tile_x?: string | undefined,
15
	tile_y?: string | undefined,
16
	tile_zoom?: string | undefined,
17
	min_lat?: string | undefined,
18
	min_lon?: string | undefined,
19
	max_lat?: string | undefined,
20
	max_lon?: string | undefined,
21
	key?: string | undefined
22
) {
23
	const url = new URL(`https://www.meteosource.com/api/v1/${auth.tier}/map`)
24
	for (const [k, v] of [
25
		['tile_x', tile_x],
26
		['tile_y', tile_y],
27
		['tile_zoom', tile_zoom],
28
		['min_lat', min_lat],
29
		['min_lon', min_lon],
30
		['max_lat', max_lat],
31
		['max_lon', max_lon],
32
		['variable', variable],
33
		['datetime', datetime],
34
		['key', key]
35
	]) {
36
		if (v !== undefined && v !== '') {
37
			url.searchParams.append(k, v)
38
		}
39
	}
40
	const response = await fetch(url, {
41
		method: 'GET',
42
		headers: {
43
			'X-API-Key': auth.apiKey
44
		},
45
		body: undefined
46
	})
47
	if (!response.ok) {
48
		const text = await response.text()
49
		throw new Error(`${response.status} ${text}`)
50
	}
51
	return await response.text()
52
}
53