MapLibre

Overview

MapLibre GL JS is an open-source TypeScript library for publishing interactive, customizable vector tile maps on the web. It is a community-maintained fork of Mapbox GL JS v1.13, created after Mapbox changed its license. MapLibre provides WebGL-powered rendering for smooth, responsive maps.

Key Features

FeatureDescription
WebGL RenderingHardware-accelerated, smooth 60fps
Vector TilesStyle data on the client
3D TerrainTerrain and sky rendering
Custom StylesFull control over map appearance
Open SourceBSD-3-Clause license
Cross-platformWeb, iOS, Android, Qt, Flutter

Ecosystem

ComponentDescriptionLinks
MapLibre GL JSWeb mapping libraryDocs
MapLibre NativeiOS/Android SDKGitHub
MapLibre Style SpecStyle specificationSpec
MartinVector tile serverGitHub

Basic Usage

HTML Setup

<!DOCTYPE html>
<html>
<head>
  <link href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" rel="stylesheet" />
  <script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
</head>
<body>
  <div id="map" style="width: 100%; height: 400px;"></div>
  <script>
    const map = new maplibregl.Map({
      container: 'map',
      style: 'https://demotiles.maplibre.org/style.json',
      center: [-122.4, 37.8],
      zoom: 9
    });
  </script>
</body>
</html>

React Integration

import Map from 'react-map-gl/maplibre';
import 'maplibre-gl/dist/maplibre-gl.css';
 
function App() {
  return (
    <Map
      initialViewState={{
        longitude: -122.4,
        latitude: 37.8,
        zoom: 9
      }}
      style={{ width: '100%', height: 400 }}
      mapStyle="https://demotiles.maplibre.org/style.json"
    />
  );
}

Style Specification

MapLibre uses a JSON style specification compatible with Mapbox:

{
  "version": 8,
  "name": "My Style",
  "sources": {
    "osm": {
      "type": "vector",
      "url": "https://tiles.example.com/data.json"
    }
  },
  "layers": [
    {
      "id": "water",
      "type": "fill",
      "source": "osm",
      "source-layer": "water",
      "paint": {
        "fill-color": "#0077be"
      }
    }
  ]
}

Free Tile Providers

ProviderDescriptionLinks
MapTilerFree tier availableWebsite
Stadia MapsFree tier with attributionWebsite
ProtomapsPMTiles hostingWebsite
OpenFreeMapFree OSM tilesWebsite

Comparison with Alternatives

LibraryRenderingLicenseVector TilesBest For
MapLibre GLWebGLBSD-3YesModern vector maps
Leaflet.jsDOM/CanvasBSD-2Via pluginsSimple maps
OpenLayersCanvas/WebGLBSD-2YesComplex GIS
Mapbox GLWebGLProprietaryYesPremium features

Appendix

Created: 2024-12-23 | Modified: 2024-12-23

See Also


(c) No Clocks, LLC | 2024