Maptoolkit Maps JS
This example adds the current temperature data as a fill layer to a Maptoolkit map using the Weather API vector tile source. The color ramp maps temperatures from blue (cold) to red (hot).
const API_KEY = 'YOUR_API_KEY';
const map = new maptoolkit.Map({
container: 'map',
apiKey: API_KEY,
style: `https://styles.maptoolkit.net/maptoolkit/maptoolkit.summer.json?api_key=${API_KEY}`,
center: [13.0, 47.5],
zoom: 5,
attributionControl: { compact: false }
});
map.addControl(new maptoolkit.NavigationControl(), 'top-right');
map.on('load', () => {
map.addSource('weather', {
type: 'vector',
url: `https://weather.maptoolkit.net/vector/icon.0.json?api_key=${API_KEY}`,
});
const firstSymbolId = (map.getStyle().layers.find((l) => l.type === 'symbol') || {}).id;
map.addLayer({
id: 'weather-temperature',
type: 'fill',
source: 'weather',
'source-layer': 'temperature',
paint: {
'fill-color': [
'interpolate', ['linear'], ['get', 'degree'],
-20, '#313695',
0, '#74add1',
10, '#fee090',
20, '#f46d43',
35, '#a50026'
],
'fill-opacity': 0.6,
},
}, firstSymbolId);
});<!DOCTYPE html>
<html lang="en">
<head>
<title>Weather - Maptoolkit Maps JS</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://unpkg.com/@maptoolkit/[email protected]/dist/maptoolkit.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@maptoolkit/[email protected]/dist/maptoolkit.css" />
<style>
html, body { width: 100%; height: 100%; margin: 0; padding: 0; }
#map { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
const API_KEY = 'YOUR_API_KEY';
const map = new maptoolkit.Map({
container: 'map',
apiKey: API_KEY,
style: `https://styles.maptoolkit.net/maptoolkit/maptoolkit.summer.json?api_key=${API_KEY}`,
center: [13.0, 47.5],
zoom: 5,
attributionControl: { compact: false }
});
map.addControl(new maptoolkit.NavigationControl(), 'top-right');
map.on('load', () => {
map.addSource('weather', {
type: 'vector',
url: `https://weather.maptoolkit.net/vector/icon.0.json?api_key=${API_KEY}`,
});
const firstSymbolId = (map.getStyle().layers.find((l) => l.type === 'symbol') || {}).id;
map.addLayer({
id: 'weather-temperature',
type: 'fill',
source: 'weather',
'source-layer': 'temperature',
paint: {
'fill-color': [
'interpolate', ['linear'], ['get', 'degree'],
-20, '#313695',
0, '#74add1',
10, '#fee090',
20, '#f46d43',
35, '#a50026'
],
'fill-opacity': 0.6,
},
}, firstSymbolId);
});
</script>
</body>
</html>Use the prompt below with any LLM to get the same result. Make sure the Maptoolkit MCP server is connected first — check out AI Integration & MCP to get started.
Use the Maptoolkit Connector. Create a map centered on Austria and add the current temperature as a color-coded fill layer from the Weather API.