Add a Raster Tile Source
Raster tile sources let you overlay any XYZ or TMS tile service on top of your base map in Maptoolkit Maps JS. You define the source with a tiles URL template and add a raster layer to control opacity, brightness, and other visual properties. Use this approach to add satellite imagery, weather overlays, historical maps, or any third-party raster tile service alongside your vector layers.
const API_KEY = 'YOUR_API_KEY';
const map = new maptoolkit.Map({
container: 'map',
apiKey: API_KEY,
style: {
version: 8,
sources: {
'raster-tiles': {
type: 'raster',
tiles: [`https://rtc-cdn.maptoolkit.net/rtc/toursprung-terrain/{z}/{x}/{y}.png?api_key=${API_KEY}`],
tileSize: 256
}
},
layers: [{
id: 'simple-tiles',
type: 'raster',
source: 'raster-tiles'
}]
},
center: [13.0, 47.5],
zoom: 7,
attributionControl: { compact: false }
});
map.addControl(new maptoolkit.NavigationControl(), 'top-right');<!DOCTYPE html>
<html lang="en">
<head>
<title>Add a Raster Tile Source - Maptoolkit Maps JS</title>
<meta property="og:description" content="Add a raster tile source and layer to the map." />
<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: {
version: 8,
sources: {
'raster-tiles': {
type: 'raster',
tiles: [`https://rtc-cdn.maptoolkit.net/rtc/toursprung-terrain/{z}/{x}/{y}.png?api_key=${API_KEY}`],
tileSize: 256
}
},
layers: [{
id: 'simple-tiles',
type: 'raster',
source: 'raster-tiles'
}]
},
center: [13.0, 47.5],
zoom: 7,
attributionControl: { compact: false }
});
map.addControl(new maptoolkit.NavigationControl(), 'top-right');
</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 an interactive map with zoom level 7, centered around [13.0, 47.5], using a raster tile source.