MapSnippets logoMapSnippets logo

Satellite Basemap with Leaflet

Leaflet

Display MapTiler satellite imagery with an optional labels overlay toggle using Leaflet tile layer controls.

progress_activityLoading map...
const satellite = L.tileLayer('https://api.maptiler.com/maps/satellite/256/{z}/{x}/{y}.jpg?key=YOUR_MAPTILER_KEY', {
  tileSize: 256,
  attribution: '&copy; <a href="https://www.maptiler.com/">MapTiler</a>'
});
const hybrid = L.tileLayer('https://api.maptiler.com/maps/hybrid/256/{z}/{x}/{y}.jpg?key=YOUR_MAPTILER_KEY', {
  tileSize: 256,
  attribution: '&copy; <a href="https://www.maptiler.com/">MapTiler</a>'
});
const streets = L.tileLayer('https://api.maptiler.com/maps/streets-v4/256/{z}/{x}/{y}.png?key=YOUR_MAPTILER_KEY', {
  tileSize: 256,
  attribution: '&copy; <a href="https://www.maptiler.com/">MapTiler</a> &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>'
});
const map = L.map('map', { layers: [hybrid] }).setView([41.9028, 12.4964], 12);
L.control.layers({ 'Satellite': satellite, 'Hybrid (labels)': hybrid, 'Streets': streets }).addTo(map);

How it works

MapTiler provides separate satellite (imagery only) and hybrid (imagery + labels) raster tile styles. Creating an L.tileLayer for each and adding them to L.control.layers() gives the user a radio-button switcher in the top-right corner.

The hybrid style is set as the default by including it in the map’s layers option. Switching between satellite and hybrid lets users toggle labels on and off while keeping the same aerial imagery base. The streets layer provides a standard map fallback.

Key APIs

API Description Docs
MapTiler Satellite Aerial imagery tiles docs.maptiler.com/cloud/api/maps
L.control.layers() Layer switcher leafletjs.com/reference.html#control-layers

FAQ

What is the difference between satellite and hybrid?

satellite is pure imagery with no labels. hybrid overlays road names, city labels, and points of interest on top of the satellite imagery.

What zoom levels are available for satellite?

MapTiler satellite tiles are available from zoom 0 to approximately zoom 20, depending on the region. Urban areas typically have higher resolution.

Common mistakes

  • Using the .png extension for satellite tiles: satellite tiles use .jpg for better compression
  • Including all layers in the map’s layers array: only the default layer should be in the array; the rest are managed by the layer control
  • Forgetting the API key: satellite tiles require authentication like all MapTiler tiles
auto_awesome

Build maps using Leaflet with AI

Generate code like this satellite basemap with leaflet example using the Leaflet skill in your IDE.