Convert Figma logo to code with AI

maptiler logotileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.

2,164
629
2,164
226

Top Related Projects

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL

OpenLayers

40,934

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦

MapLibre GL JS - Interactive vector tile maps in the browser

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Quick Overview

TileServer GL is an open-source map tile server for serving vector and raster maps. It's built with Node.js and supports various map styles and data formats, making it a versatile solution for hosting custom maps or serving as a local map tile server for development and testing purposes.

Pros

  • Supports both vector and raster tile serving
  • Compatible with multiple map styles (Mapbox GL Style, TileJSON, etc.)
  • Easy to set up and configure
  • Includes a built-in viewer for previewing maps

Cons

  • Performance may be limited compared to more specialized tile servers
  • Documentation could be more comprehensive
  • Limited advanced features compared to some commercial solutions
  • May require additional setup for production-level deployments

Code Examples

  1. Basic server setup:
const tileserver = require('tileserver-gl');

const options = {
  paths: {
    root: __dirname,
    styles: 'styles',
    mbtiles: 'data'
  },
  serveAllFonts: true
};

tileserver(options);
  1. Configuring a custom style:
const config = {
  styles: {
    'custom-style': {
      style: 'styles/custom-style.json',
      tilejson: {
        bounds: [-180, -85.0511, 180, 85.0511]
      }
    }
  }
};

tileserver(config);
  1. Serving raster tiles:
const config = {
  data: {
    'raster-tiles': {
      mbtiles: 'path/to/raster-tiles.mbtiles'
    }
  }
};

tileserver(config);

Getting Started

  1. Install TileServer GL:

    npm install -g tileserver-gl
    
  2. Create a configuration file config.json:

    {
      "options": {
        "paths": {
          "root": ".",
          "fonts": "fonts",
          "styles": "styles",
          "mbtiles": "data"
        }
      },
      "styles": {
        "osm-bright": {
          "style": "osm-bright/style.json",
          "tilejson": {
            "bounds": [-180, -85.0511, 180, 85.0511]
          }
        }
      },
      "data": {
        "v3": {
          "mbtiles": "zurich_switzerland.mbtiles"
        }
      }
    }
    
  3. Run the server:

    tileserver-gl-light config.json
    
  4. Access the map viewer at http://localhost:8080

Competitor Comparisons

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL

Pros of mapbox-gl-js

  • More comprehensive and feature-rich client-side rendering library
  • Extensive documentation and community support
  • Advanced styling capabilities and dynamic data visualization

Cons of mapbox-gl-js

  • Requires a Mapbox account and API key for full functionality
  • Larger file size and potentially higher resource usage
  • Steeper learning curve for beginners

Code Comparison

mapbox-gl-js:

mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
const map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v11',
    center: [-74.5, 40],
    zoom: 9
});

tileserver-gl:

const map = new maplibregl.Map({
    container: 'map',
    style: 'http://localhost:8080/styles/osm-bright/style.json',
    center: [-74.5, 40],
    zoom: 9
});

Summary

mapbox-gl-js is a powerful client-side rendering library with extensive features and styling options, backed by strong documentation and community support. However, it requires a Mapbox account and may have a steeper learning curve. tileserver-gl, on the other hand, is a self-hosted solution that doesn't require external dependencies but may have fewer advanced features. The choice between the two depends on specific project requirements, budget constraints, and desired level of customization.

OpenLayers

Pros of OpenLayers

  • More comprehensive and feature-rich library for web mapping
  • Supports a wider range of data formats and projections
  • Larger community and more extensive documentation

Cons of OpenLayers

  • Steeper learning curve due to its complexity
  • Larger file size, which may impact page load times

Code Comparison

OpenLayers:

import Map from 'ol/Map';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';

const map = new Map({
  layers: [new TileLayer({ source: new OSM() })],
  target: 'map'
});

TileServer GL:

const map = new maplibregl.Map({
  container: 'map',
  style: 'https://your-tileserver-gl-url/style.json',
  center: [0, 0],
  zoom: 2
});

Key Differences

  • OpenLayers is a full-featured mapping library, while TileServer GL is primarily a tile server with a lightweight client-side library
  • OpenLayers offers more flexibility in data handling and visualization, whereas TileServer GL focuses on serving vector tiles efficiently
  • TileServer GL is better suited for projects that require fast vector tile rendering, while OpenLayers excels in complex mapping applications with diverse data sources

Use Cases

  • Choose OpenLayers for advanced GIS functionality and complex map interactions
  • Opt for TileServer GL when you need a lightweight solution for serving and rendering vector tiles quickly
40,934

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦

Pros of Leaflet

  • Lightweight and mobile-friendly, making it ideal for web-based mapping applications
  • Extensive plugin ecosystem, allowing for easy customization and feature extension
  • Simple API and well-documented, making it accessible for beginners and experienced developers alike

Cons of Leaflet

  • Limited built-in support for vector tiles, requiring additional plugins or libraries
  • Less suitable for complex, data-heavy visualizations compared to more robust mapping libraries

Code Comparison

Leaflet (client-side map rendering):

var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: 'Β© OpenStreetMap contributors'
}).addTo(map);

TileServer GL (server-side tile generation):

const tileserver = require('tileserver-gl');
const options = {
    paths: { root: __dirname, styles: 'styles', mbtiles: 'data' },
    serveStaticMaps: true
};
tileserver(options);

While Leaflet focuses on client-side map rendering and interaction, TileServer GL is primarily used for serving vector and raster tiles on the server-side. Leaflet is more suitable for web applications requiring interactive maps, while TileServer GL is better for hosting and serving custom map tiles.

MapLibre GL JS - Interactive vector tile maps in the browser

Pros of MapLibre GL JS

  • Open-source and community-driven, allowing for greater flexibility and customization
  • Supports a wider range of map styles and data sources
  • More frequent updates and active development

Cons of MapLibre GL JS

  • Requires more setup and configuration compared to TileServer GL
  • May have a steeper learning curve for beginners
  • Less out-of-the-box functionality for serving vector tiles

Code Comparison

MapLibre GL JS:

import maplibregl from 'maplibre-gl';

const map = new maplibregl.Map({
  container: 'map',
  style: 'https://demotiles.maplibre.org/style.json',
  center: [0, 0],
  zoom: 2
});

TileServer GL:

const tileserver = require('tileserver-gl');

tileserver.startServer({
  configPath: 'config.json',
  port: 8080
});

MapLibre GL JS focuses on client-side rendering and interaction, while TileServer GL is primarily used for serving vector tiles and styles. MapLibre GL JS offers more flexibility in map creation and customization, but requires more client-side code. TileServer GL provides a simpler setup for serving tiles but with less customization options on the client side.

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Pros of mapbox-gl-native

  • More comprehensive and feature-rich, offering a complete mapping solution
  • Better performance for complex rendering and large datasets
  • Supports offline maps and custom style rendering

Cons of mapbox-gl-native

  • Larger codebase and more complex to implement
  • Requires more resources and may have a higher learning curve
  • Proprietary license, which may limit usage in some projects

Code Comparison

mapbox-gl-native:

#include <mbgl/map/map.hpp>
#include <mbgl/style/style.hpp>

mbgl::Map map(view);
map.getStyle().loadURL("mapbox://styles/mapbox/streets-v11");
map.setCenter(mbgl::LatLng(40.7128, -74.0060));
map.setZoom(12);

tileserver-gl:

const server = require('tileserver-gl');
const config = {
  styles: {
    'osm-bright': './styles/osm-bright/style.json'
  },
  data: {
    'osm': { mbtiles: './data/osm.mbtiles' }
  }
};
server.startServer(config);

mapbox-gl-native offers more direct control over map rendering and styling, while tileserver-gl focuses on serving map tiles and styles. The former is better suited for custom map applications, while the latter is ideal for quickly setting up a tile server.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

tileserver-gl

TileServer GL

GitHub Workflow Status Docker Hub

Vector and raster maps with GL styles. Server-side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.

Download vector tiles from OpenMapTiles.

Getting Started with Node

Make sure you have Node.js version 18.17.0 or above installed. Node 20 is recommended. (running node -v it should output something like v20.x.x). Running without docker requires Native dependencies to be installed first.

Install tileserver-gl with server-side raster rendering of vector tiles with npm.

npm install -g tileserver-gl

Once installed, you can use it like the following examples.

using a mbtiles file

wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles
tileserver-gl --file zurich_switzerland.mbtiles
[in your browser, visit http://[server ip]:8080]

using a config.json + style + mbtiles file

wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
unzip test_data.zip
tileserver-gl
[in your browser, visit http://[server ip]:8080]

Alternatively, you can use the tileserver-gl-light npm package instead, which is pure javascript, does not have any native dependencies, and can run anywhere, but does not contain rasterization on the server side made with Maplibre GL Native.

Getting Started with Docker

An alternative to npm to start the packed software easier is to install Docker on your computer and then run from the tileserver-gl directory

Example using a mbtiles file

wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl --file zurich_switzerland.mbtiles
[in your browser, visit http://[server ip]:8080]

Example using a config.json + style + mbtiles file

wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
unzip test_data.zip
docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl
[in your browser, visit http://[server ip]:8080]

Example using a different path

docker run --rm -it -v /your/local/config/path:/data -p 8080:8080 maptiler/tileserver-gl

replace '/your/local/config/path' with the path to your config file

Alternatively, you can use the maptiler/tileserver-gl-light docker image instead, which is pure javascript, does not have any native dependencies, and can run anywhere, but does not contain rasterization on the server side made with Maplibre GL Native.

Getting Started with Linux cli

Test from command line

wget https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/test_data.zip
unzip -q test_data.zip -d test_data
xvfb-run --server-args="-screen 0 1024x768x24" npm test

Run from command line

xvfb-run --server-args="-screen 0 1024x768x24" node .

Documentation

You can read the full documentation of this project at https://tileserver.readthedocs.io/en/latest/.

Alternative

Discover MapTiler Server if you need a map server with easy setup and user-friendly interface.

NPM DownloadsLast 30 Days