### Install and Start TileServer GL with npm Source: https://context7.com/maptiler/tileserver-gl/llms.txt Installs TileServer GL globally using npm and provides commands to start the server with an MBTiles file or a configuration file. Also includes installation for the light variant. ```bash # Install native deps on Ubuntu 24.04 apt install build-essential python3-setuptools pkg-config xvfb libglfw3-dev \ libuv1-dev libjpeg-turbo8 libicu-dev libcairo2-dev libpango1.0-dev \ libpng-dev libjpeg-dev libgif-dev librsvg2-dev libcurl4-openssl-dev libpixman-1-dev npm install -g tileserver-gl # Start with a single MBTiles file (auto-generates config + default styles) tileserver-gl --file zurich_switzerland.mbtiles # → Open http://localhost:8080 # Start with a full config.json tileserver-gl --config /data/config.json --port 8080 # Light variant (pure JS, no native deps, no server-side raster rendering) npm install -g tileserver-gl-light tileserver-gl-light --file data.mbtiles ``` -------------------------------- ### Install TileServer GL locally from source Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/installation.md Clone the TileServer GL repository, navigate into the directory, install dependencies using npm, and then run the server locally. ```bash git clone https://github.com/maptiler/tileserver-gl.git cd tileserver-gl npm install node . ``` -------------------------------- ### Tileserver GL Configuration Example Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/config.md This is a comprehensive example of a Tileserver GL configuration file. It demonstrates how to set up paths, allowed domains, format options, and style definitions. ```json { "options": { "paths": { "root": "", "fonts": "fonts", "sprites": "sprites", "icons": "icons", "styles": "styles", "mbtiles": "data", "pmtiles": "data", "files": "files" }, "domains": [ "localhost:8080", "127.0.0.1:8080" ], "allowedHosts": "localhost,myapp.example.com", "formatOptions": { "jpeg": { "quality": 80 }, "webp": { "quality": 90 } }, "maxScaleFactor": 3, "maxSize": 2048, "pbfAlias": "pbf", "serveAllFonts": false, "serveAllStyles": false, "serveStaticMaps": true, "allowRemoteMarkerIcons": true, "allowInlineMarkerImages": true, "staticAttributionText": "© OpenMapTiles © OpenStreetMaps", "tileMargin": 0 }, "styles": { "basic": { "style": "basic.json", "tilejson": { "type": "overlay", "bounds": [8.44806, 47.32023, 8.62537, 47.43468] } }, "hybrid": { "style": "satellite-hybrid.json", "serve_rendered": false, "tilejson": { "format": "webp" } }, "remote": { "style": "https://demotiles.maplibre.org/style.json" } }, "data": { "zurich-vector": { "mbtiles": "zurich.mbtiles" } } } ``` -------------------------------- ### Start TileServer GL with Docker Source: https://context7.com/maptiler/tileserver-gl/llms.txt Provides Docker commands to run TileServer GL, including basic setup, specifying a file, enabling verbose logging, and reloading configuration via SIGHUP. ```bash # Basic: map current directory as /data, expose port 8080 docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl:latest # Explicit file docker run --rm -it -v $(pwd):/data -p 8080:8080 \ maptiler/tileserver-gl:latest --file zurich_switzerland.mbtiles # With verbose logging and a fixed public URL docker run --rm -it -v $(pwd):/data -p 8080:8080 \ maptiler/tileserver-gl:latest \ --public_url https://tiles.example.com/ \ --verbose 2 # Reload config without restart (SIGHUP) docker kill -s HUP ``` -------------------------------- ### Install tileserver-gl with npm Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Install the tileserver-gl package globally using npm. Ensure Node.js version 20 or above is installed. ```bash npm install -g tileserver-gl ``` -------------------------------- ### Run tileserver-gl from Linux command line Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Start the tileserver-gl server using Node.js within a virtual framebuffer environment. ```bash xvfb-run --server-args="-screen 0 1024x768x24" node . ``` -------------------------------- ### Run Tileserver GL with Basic S3 URL Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using a PMTiles file from an AWS S3 bucket. ```default tileserver-gl --file s3://my-bucket/tiles.pmtiles ``` -------------------------------- ### Run Tileserver GL with Local MBTiles Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using a local MBTiles file as the data source. ```default tileserver-gl --file ./data/zurich.mbtiles ``` -------------------------------- ### Run Tileserver GL with All S3 Options Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using an S3 PMTiles file with multiple options including profile, region, and requester pays. ```default tileserver-gl --file "s3://bucket/tiles.pmtiles?profile=prod®ion=us-west-2&requestPayer=true" ``` -------------------------------- ### Run Tileserver GL with Requester Pays S3 Bucket Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using an S3 PMTiles file from a requester-pays bucket. ```default tileserver-gl --file "s3://bucket/tiles.pmtiles?requestPayer=true" ``` -------------------------------- ### Run Tileserver GL with Local PMTiles Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using a local PMTiles file as the data source. ```default tileserver-gl --file ./data/terrain.pmtiles ``` -------------------------------- ### Install TileServer GL globally via npm Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/installation.md Install the TileServer GL package globally using npm. After installation, you can run the tileserver-gl command from anywhere. ```bash npm install -g tileserver-gl tileserver-gl ``` -------------------------------- ### Run tileserver-gl with config, style, and MBTiles Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Start the tileserver-gl using a configuration file, style, and MBTiles file. Download and unzip the test data first. The server will be accessible at http://[server ip]:8080. ```bash 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] ``` -------------------------------- ### Run Tileserver GL with S3-Compatible Storage Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using a PMTiles file from an S3-compatible storage service, specifying the endpoint and profile. ```default tileserver-gl --file "s3://example-storage.com/my-bucket/tiles.pmtiles?profile=dev" ``` -------------------------------- ### Run tileserver-gl with Docker and a custom path Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Start the tileserver-gl using Docker, mounting a specified local path to /data and mapping port 8080. Replace '/your/local/config/path' with the actual path to your configuration files. ```bash docker run --rm -it -v /your/local/config/path:/data -p 8080:8080 maptiler/tileserver-gl:latest ``` -------------------------------- ### Run Tileserver GL with S3 URL and Profile Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using an S3 PMTiles file, specifying an AWS credential profile. ```default tileserver-gl --file "s3://my-bucket/tiles.pmtiles?profile=production" ``` -------------------------------- ### Run Tileserver GL with HTTP/HTTPS PMTiles Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using a PMTiles file hosted at a remote HTTP or HTTPS URL. ```default tileserver-gl --file https://example.com/tiles.pmtiles ``` -------------------------------- ### Run Tileserver GL with S3 URL and Region Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using an S3 PMTiles file, specifying the AWS region. ```default tileserver-gl --file "s3://my-bucket/tiles.pmtiles?region=us-west-2" ``` -------------------------------- ### Run tileserver-gl with an MBTiles file Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Start the tileserver-gl using a local MBTiles file. The server will be accessible at http://[server ip]:8080. ```bash 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] ``` -------------------------------- ### Run Tileserver GL with Explicit MBTiles URL Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using an MBTiles file specified with the 'mbtiles://' protocol prefix, pointing to a local path. ```default tileserver-gl --file mbtiles://./data/zurich.mbtiles ``` -------------------------------- ### Run tileserver-gl with Docker, config, style, and MBTiles Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Start the tileserver-gl using Docker with a configuration file, style, and MBTiles file. Mount the current directory to /data and map port 8080. The server will be accessible at http://[server ip]:8080. ```bash 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:latest [in your browser, visit http://[server ip]:8080] ``` -------------------------------- ### Configure Data Source for Elevation Queries Source: https://context7.com/maptiler/tileserver-gl/llms.txt Example JSON configuration for a data source to enable elevation queries, specifying the tile source and encoding format. ```json { "data": { "terrain": { "pmtiles": "terrain-rgb.pmtiles", "encoding": "mapbox", "tileSize": 512 } } } ``` -------------------------------- ### Run Tileserver GL with Explicit PMTiles URL Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using a PMTiles file specified with the 'pmtiles://' protocol prefix, pointing to an HTTP/HTTPS URL. ```default tileserver-gl --file pmtiles://https://example.com/tiles.pmtiles ``` -------------------------------- ### Run Tileserver GL with S3 URL, Profile, and Region Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using an S3 PMTiles file, specifying both an AWS credential profile and the region. ```default tileserver-gl --file "s3://my-bucket/tiles.pmtiles?profile=production®ion=eu-central-1" ``` -------------------------------- ### Run Tileserver GL with Explicit PMTiles S3 URL Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using a PMTiles file specified with the 'pmtiles://' protocol prefix, pointing to an S3 URL with profile. ```default tileserver-gl --file "pmtiles://s3://my-bucket/tiles.pmtiles?profile=production" ``` -------------------------------- ### Run tileserver-gl with Docker and an MBTiles file Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Start the tileserver-gl using Docker with a local MBTiles file. Mount the current directory to /data and map port 8080. The server will be accessible at http://[server ip]:8080. ```bash 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:latest --file zurich_switzerland.mbtiles [in your browser, visit http://[server ip]:8080] ``` -------------------------------- ### Get Specific Style JSON Source: https://context7.com/maptiler/tileserver-gl/llms.txt Fetches the JSON definition for a specific style. This is the primary file defining a style's layers and sources. ```bash # Get a specific style JSON curl http://localhost:8080/styles/basic/style.json ``` -------------------------------- ### Run Tileserver GL with S3 Bucket Name Containing Dots Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Starts Tileserver GL using an S3 PMTiles file where the bucket name contains dots, forcing AWS S3 interpretation. ```default tileserver-gl --file "s3://my.bucket.name/tiles.pmtiles?s3UrlFormat=aws" ``` -------------------------------- ### Get WMTS Capabilities Source: https://context7.com/maptiler/tileserver-gl/llms.txt Fetches the Web Map Tile Service (WMTS) capabilities document for a given style. This allows integration with clients that support the WMTS standard. ```bash # WMTS capabilities curl "http://localhost:8080/styles/basic/wmts.xml" ``` -------------------------------- ### Set AWS Credentials via Environment Variables Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/config.md Configure AWS credentials for S3 access using environment variables. Ensure these variables are set before starting the TileServer-GL instance. ```bash export AWS_ACCESS_KEY_ID=your_access_key export AWS_SECRET_ACCESS_KEY=your_secret_key export AWS_REGION=us-west-2 ``` -------------------------------- ### Build Docker Image for TileServer GL light Source: https://github.com/maptiler/tileserver-gl/blob/master/README_light.md Clone the repository, navigate to the light directory, and build the Docker image. ```bash git clone https://github.com/maptiler/tileserver-gl.git cd tileserver-gl node publish.js --no-publish cd light docker build -t tileserver-gl-light . ``` -------------------------------- ### Get Sprite Sheet Image Source: https://context7.com/maptiler/tileserver-gl/llms.txt Downloads the sprite sheet image file. Supports different pixel ratios. ```bash # Get sprite image curl http://localhost:8080/styles/basic/sprite.png -o sprite.png curl http://localhost:8080/styles/basic/sprite@2x.png -o sprite@2x.png ``` -------------------------------- ### Tileserver GL Command-Line Help Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Displays all available command-line options for running Tileserver GL, including file input, port binding, CORS settings, and logging. ```default Usage: tileserver-gl [file] [options] Options: --file MBTiles or PMTiles file (local path, http(s)://, s3://, pmtiles://, or mbtiles:// URL) ignored if the configuration file is also specified --mbtiles (DEPRECIATED) MBTiles file ignored if file is also specified ignored if the configuration file is also specified -c, --config Configuration file [config.json] (default: "config.json") -b, --bind
Bind address -p, --port Port [8080] (default: 8080) -C|--no-cors Disable Cross-origin resource sharing headers -u|--public_url Enable exposing the server on subpaths, not necessarily the root of the domain --fetch-timeout Timeout in milliseconds for fetching remote tiles (default: 15000) --ignore-missing-files Do not exit when referenced data files or remote sources are missing at startup; log a warning and continue running (useful when styles reference optional or not-yet-available sources) -V, --verbose [level] More verbose output (level 1-3) -V, --verbose, -V 1, or --verbose 1: Important operations -V 2 or --verbose 2: Detailed operations -V 3 or --verbose 3: All requests and debug info -s, --silent Less verbose output -l|--log_file output log file (defaults to standard out) -f|--log_format define the log format: https://github.com/expressjs/morgan#morganformat-options -v, --version output the version number -h, --help display help for command ``` -------------------------------- ### Build and Push Main Docker Image Source: https://github.com/maptiler/tileserver-gl/blob/master/PUBLISHING.md Build the main tileserver-gl Docker image using buildx for multi-platform support and tag it with both 'latest' and the specific version. Then, push all tags to the registry. ```bash # Build the main image docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl:latest -t maptiler/tileserver-gl:X.X.X . # Replace X.X.X docker push maptiler/tileserver-gl --all-tags ``` -------------------------------- ### Build and Publish Both NPM Packages Source: https://github.com/maptiler/tileserver-gl/blob/master/PUBLISHING.md Use the publish.js script to build the light version and publish both tileserver-gl and tileserver-gl-light to NPM. This script automates the process for both packages. ```bash # This script builds the light version and publishes both tileserver-gl and tileserver-gl-light to NPM. node publish.js ``` -------------------------------- ### Build and Push Light Docker Image Source: https://github.com/maptiler/tileserver-gl/blob/master/PUBLISHING.md Build the tileserver-gl-light Docker image within the 'light' subdirectory, tagging it with 'latest' and the specific version. Push all tags to the registry. Ensure you are logged into Docker before pushing. ```bash # Build the light image cd light docker buildx build --platform linux/amd64 -t maptiler/tileserver-gl-light:latest -t maptiler/tileserver-gl-light:X.X.X . # Replace X.X.X docker push maptiler/tileserver-gl-light --all-tags cd .. # Return to the project root ``` -------------------------------- ### TileServer GL CLI Options Reference Source: https://context7.com/maptiler/tileserver-gl/llms.txt Lists available command-line options for tileserver-gl, including file input, configuration, port, CORS, public URL, timeouts, verbosity, and logging. ```bash tileserver-gl [file] [options] # Options reference: # --file MBTiles or PMTiles file (local, http(s)://, s3://, pmtiles://, mbtiles://) # -c, --config Configuration file (default: config.json) # -b, --bind
Bind address # -p, --port Port (default: 8080) # -C|--no-cors Disable CORS headers # -u|--public_url Canonical public URL (recommended for production) # --fetch-timeout Remote tile fetch timeout in ms (default: 15000) # --ignore-missing-files Skip missing data files at startup instead of exiting # -V, --verbose [1-3] Verbosity: 1=important, 2=detailed, 3=all requests/debug # -s, --silent Suppress output # -l|--log_file Log to file instead of stdout # -f|--log_format Morgan log format # -v, --version Show version # Examples tileserver-gl --file ./data/world.pmtiles --public_url https://maps.example.com/ -V 1 tileserver-gl -c config.json --fetch-timeout 30000 --ignore-missing-files tileserver-gl --file "s3://my-bucket/tiles.pmtiles?profile=prod®ion=eu-central-1" ``` -------------------------------- ### Test tileserver-gl from Linux command line Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Prepare test data and run the npm test command within a virtual framebuffer environment for testing. ```bash 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 ``` -------------------------------- ### Get Sprite Sheet JSON Index Source: https://context7.com/maptiler/tileserver-gl/llms.txt Retrieves the JSON index for a sprite sheet, which maps sprite names to their coordinates and dimensions. Supports different pixel ratios. ```bash # Get sprite sheet (JSON index) curl http://localhost:8080/styles/basic/sprite.json curl http://localhost:8080/styles/basic/sprite@2x.json ``` -------------------------------- ### Run TileServer GL light with Docker Source: https://github.com/maptiler/tileserver-gl/blob/master/README_light.md Run the TileServer GL light Docker container, mapping the current directory to /data and exposing port 8080. ```bash docker run --rm -it -v $(pwd):/data -p 8080:8080 tileserver-gl-light ``` -------------------------------- ### Get TileJSON for Rendered Style Source: https://context7.com/maptiler/tileserver-gl/llms.txt Provides TileJSON metadata for a rendered style, suitable for use with clients like MapLibre GL JS. Includes the tile URL template. ```bash # TileJSON for rendered style (for use in MapLibre GL JS) curl "http://localhost:8080/styles/basic.json" # Response: { "tilejson": "2.0.0", "tiles": ["http://localhost:8080/styles/basic/{z}/{x}/{y}.png"], ... } ``` -------------------------------- ### Get Font Glyph PBF Data Source: https://context7.com/maptiler/tileserver-gl/llms.txt Fetches font glyph data in Protocol Buffer format (PBF) for a specific font stack and range of character codes. Required for rendering text on maps. ```bash # Get font glyph PBF curl "http://localhost:8080/fonts/Open%20Sans%20Regular/0-255.pbf" -o glyphs.pbf ``` -------------------------------- ### Build Light NPM Package Only Source: https://github.com/maptiler/tileserver-gl/blob/master/PUBLISHING.md Use the publish.js script with the --no-publish flag to only build the light version of tileserver-gl. This is useful for local testing or creating Docker images without publishing to NPM. ```bash # This script ONLY builds the light version (e.g., for local testing or Docker image creation) without publishing. node publish.js --no-publish ``` -------------------------------- ### Create and Push Git Tag Source: https://github.com/maptiler/tileserver-gl/blob/master/PUBLISHING.md Create a Git tag for the new version and push it to the remote repository. Ensure the tag format matches the version number. ```bash git tag vX.X.X # Replace X.X.X with the version number git push origin --tags ``` -------------------------------- ### Enable verbose logging with Docker Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/installation.md To see the default configuration created automatically by TileServer GL when running via Docker, append the --verbose flag to the command. ```bash docker run ... maptiler/tileserver-gl --verbose ``` -------------------------------- ### Run TileServer GL with Docker Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/installation.md Execute the TileServer GL Docker image. This command automatically downloads the image if not present and maps the current directory to /data within the container, exposing port 8080. ```bash docker run --rm -it -v $(pwd):/data -p 8080:8080 maptiler/tileserver-gl ``` -------------------------------- ### List All Available Styles (TileJSON) Source: https://context7.com/maptiler/tileserver-gl/llms.txt Retrieves a TileJSON array of all styles available on the server. Useful for discovering available styles. ```bash # List all available styles (TileJSON array) curl http://localhost:8080/styles.json ``` -------------------------------- ### NPM Publish Full Version Source: https://github.com/maptiler/tileserver-gl/blob/master/PUBLISHING.md Publish only the full tileserver-gl package to NPM with public access. This is one of the options for NPM publishing. ```bash npm publish --access public ``` -------------------------------- ### Mount AWS Credentials for Docker Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/usage.md Demonstrates how to mount the local AWS credentials file into a Docker container running Tileserver GL, enabling S3 access. ```default docker run -v ~/.aws/credentials:/home/node/.aws/credentials:ro ... maptiler/tileserver-gl:latest ``` -------------------------------- ### Configure Local and URL-based PMTiles Sources Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/config.md Specify PMTiles sources using local file paths or URLs. TileServer-GL will resolve local files relative to the 'root' + 'pmtiles' path. ```json "sources": { "source2": { "url": "pmtiles://source2.pmtiles", "type": "vector" }, "source3": { "url": "pmtiles://https://foo.lan/source3.pmtiles", "type": "vector" } } ``` -------------------------------- ### Render Static Map with Markers Source: https://context7.com/maptiler/tileserver-gl/llms.txt Generate static map images with custom markers. Markers can include icons, scales, and offsets. Ensure icons are in the configured path or accessible remotely if allowed. ```bash curl "http://localhost:8080/styles/basic/static/8.55,47.37,12/800x600.png?\nmarker=8.55,47.37|marker-icon.png|scale:0.5|offset:0,-12" -o with-marker.png ``` -------------------------------- ### Request Raster Tile with Custom Size and Format Source: https://context7.com/maptiler/tileserver-gl/llms.txt Fetches a raster tile with a specified tile size (e.g., 512px) and image format (e.g., WebP). Supports various formats like PNG, JPEG, and WebP. ```bash # 512px WebP tile curl "http://localhost:8080/styles/basic/512/10/550/357.webp" -o tile512.webp ``` -------------------------------- ### Render Static Map with Multiple Paths and Markers (POST) Source: https://context7.com/maptiler/tileserver-gl/llms.txt Generate static map images using a POST request with a JSON body. This method supports multiple paths and markers, as well as padding. ```bash curl -X POST "http://localhost:8080/styles/basic/static/auto/800x600.png" \ -H "Content-Type: application/json" \ -d '{ "path": [ "stroke:blue|width:2|8.44,47.32|8.63,47.43", "stroke:red|width:1|8.50,47.35|8.60,47.40" ], "marker": ["8.55,47.37|marker-icon.png|scale:0.5"], "padding": "0.1" }' -o multi-path.png ``` -------------------------------- ### Configure Data Sources in tileserver-gl Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/config.md Define various data sources like terrain, vector tiles, and S3-based PMTiles. Supports different file formats and S3 configurations. ```default "data": { "terrain": { "mbtiles": "terrain1.mbtiles", "encoding": "mapbox", "tileSize": 512 }, "vector_tiles": { "pmtiles": "custom_osm.pmtiles" }, "production-s3-tiles": { "pmtiles": "s3://prod-bucket/tiles.pmtiles", "s3Profile": "production" } } ``` -------------------------------- ### Set Fixed Public URL for tileserver-gl Source: https://github.com/maptiler/tileserver-gl/blob/master/SECURITY.md Recommended for production environments to prevent Host Header Poisoning by specifying a canonical base URL. This option ignores incoming Host and X-Forwarded headers for URL construction. ```bash tileserver-gl --public_url https://your-domain.com/ -c config.json ``` -------------------------------- ### Configure Data Sources Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/config.md Define data sources for the server. Supports MBTiles and PMTiles formats, including remote URLs and S3 paths for PMTiles. ```json "data": { "source1": { "mbtiles": "source1.mbtiles" }, "source2": { "pmtiles": "source2.pmtiles" }, "source3": { "pmtiles": "https://foo.lan/source3.pmtiles" }, "source4": { "pmtiles": "s3://my-bucket/tiles/terrain.pmtiles" } } ``` -------------------------------- ### PNG Format Options for Image Generation Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/config.md Configure PNG specific options for image generation, such as palette usage and color count. These options are passed to the sharp library. ```json "formatOptions": { "png": { "palette": true, "colors": 4 } } ``` -------------------------------- ### Serve Raw Tile Data Source: https://context7.com/maptiler/tileserver-gl/llms.txt Serve raw tile data directly from MBTiles/PMTiles sources. Supports vector PBF, raster PNG/WebP, and GeoJSON inspection for vector sources. ```bash curl "http://localhost:8080/data/zurich-vector/10/550/357.pbf" -o tile.pbf ``` ```bash curl "http://localhost:8080/data/zurich-vector/10/550/357.geojson" | jq .features[0] ``` ```bash curl "http://localhost:8080/data/zurich-vector.json" ``` ```bash curl "http://localhost:8080/data.json" ``` ```bash curl "http://localhost:8080/files/my-geojson-overlay.geojson" ``` -------------------------------- ### Render Static Map by Bounding Box Source: https://context7.com/maptiler/tileserver-gl/llms.txt Generate static map images using bounding box coordinates (minx, miny, maxx, maxy) instead of a center point. Specify dimensions and format. ```bash curl "http://localhost:8080/styles/basic/static/8.44,47.32,8.63,47.43/1024x768.png" -o bbox.png ``` -------------------------------- ### AWS S3 PMTiles Source Configuration Source: https://context7.com/maptiler/tileserver-gl/llms.txt Access PMTiles files directly from AWS S3 or S3-compatible storage using the TileServer GL CLI. Configure AWS credentials or use a credentials file, and specify S3 bucket details and optional parameters like profile, region, or requestPayer. ```bash # Configure credentials export AWS_ACCESS_KEY_ID=your_key export AWS_SECRET_ACCESS_KEY=your_secret export AWS_REGION=us-west-2 # Or use ~/.aws/credentials with named profiles: # [production] # aws_access_key_id=PROD_KEY # aws_secret_access_key=PROD_SECRET # Start with S3 PMTiles directly via CLI tileserver-gl --file "s3://my-bucket/world.pmtiles?profile=production®ion=us-west-2" # Requester-pays bucket tileserver-gl --file "s3://bucket/tiles.pmtiles?requestPayer=true" # AWS bucket name with dots (force AWS URL format detection) tileserver-gl --file "s3://my.bucket.name/tiles.pmtiles?s3UrlFormat=aws" # S3-compatible storage (DigitalOcean Spaces, MinIO, Contabo, etc.) tileserver-gl --file "s3://nyc3.digitaloceanspaces.com/my-bucket/tiles.pmtiles" # Mount AWS credentials file into Docker container docker run --rm -it \ -v $(pwd):/data \ -v ~/.aws/credentials:/home/node/.aws/credentials:ro \ -p 8080:8080 \ maptiler/tileserver-gl:latest \ --file "s3://prod-bucket/world.pmtiles?profile=production" ``` -------------------------------- ### Specify MBTiles file with Docker Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/installation.md When using the Docker image, you can explicitly specify which MBTiles file to use by appending the --file option to the command. ```bash docker run ... maptiler/tileserver-gl --file my-tiles.mbtiles ``` -------------------------------- ### Configure S3 PMTiles Data Sources Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/config.md Configure PMTiles data sources using S3. Supports direct S3 URLs with query parameters for profile, region, and request payer, or configuration properties for profile, region, and URL format. ```default "data": { "us-west-tiles": { "pmtiles": "s3://prod-bucket/tiles.pmtiles?profile=production®ion=us-west-2" }, "dotted-bucket-name": { "pmtiles": "s3://my.bucket.name/tiles.pmtiles?s3UrlFormat=aws®ion=us-east-1" }, "eu-requester-pays": { "pmtiles": "s3://bucket/tiles.pmtiles?profile=prod®ion=eu-central-1&requestPayer=true" } } ``` ```default "data": { "us-west-tiles": { "pmtiles": "s3://prod-bucket/tiles.pmtiles", "s3Profile": "production", "s3Region": "us-west-2" }, "dotted-bucket-name": { "pmtiles": "s3://my.bucket.name/tiles.pmtiles", "s3UrlFormat": "aws", "s3Region": "us-east-1" }, "eu-requester-pays": { "pmtiles": "s3://bucket/tiles.pmtiles", "s3Profile": "production", "s3Region": "eu-central-1", "requestPayer": true } } ``` -------------------------------- ### Render Static Map with Auto-Fit Path Source: https://context7.com/maptiler/tileserver-gl/llms.txt Generate static map images that automatically fit a specified path. The path can be defined by a series of coordinates or a Google Encoded Polyline. ```bash curl "http://localhost:8080/styles/basic/static/auto/800x600.png?\npath=stroke:red|width:3|8.44,47.32|8.63,47.32|8.63,47.43|8.44,47.43|8.44,47.32" -o autofit.png ``` ```bash curl "http://localhost:8080/styles/basic/static/auto/640x480.png?path=enc:_p~iF~ps|U_ulLnnqC_mqNvxq%60" -o polyline.png ``` -------------------------------- ### Configure Requester Pays for S3 PMTiles Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/config.md Enable 'requester pays' for S3 buckets to cover data transfer costs. This setting can be applied via a URL parameter or a configuration property, with the property taking precedence. ```json "pmtiles": "s3://bucket/tiles.pmtiles?requestPayer=true" ``` ```json "pmtiles": "s3://bucket/tiles.pmtiles", "requestPayer": true ``` -------------------------------- ### Set Public URL for Tileserver GL Source: https://github.com/maptiler/tileserver-gl/blob/master/README.md Configure Tileserver GL with a canonical public URL to prevent host derivation from request headers. This is the recommended approach for production environments. ```bash tileserver-gl --public_url https://your-domain.com/ --file your.mbtiles ``` -------------------------------- ### Static Files Serving Source: https://github.com/maptiler/tileserver-gl/blob/master/docs/endpoints.md Serves static files from a configured directory. Useful for serving geojson files for styles. ```APIDOC ## GET /files/{filename} ### Description Serves static files from a configured directory (default is `public/files`). This can be used to serve geojson files for styles. ### Method GET ### Endpoint `/files/{filename}` ### Parameters #### Path Parameters - **filename** (string) - Required - The name of the file to serve. ``` -------------------------------- ### Index of All Rendered TileJSONs Source: https://context7.com/maptiler/tileserver-gl/llms.txt Provides an index of TileJSON endpoints for all rendered styles, optionally specifying tile size. Useful for discovering available tile sets. ```bash # Index of all rendered TileJSONs curl "http://localhost:8080/index.json" curl "http://localhost:8080/512/index.json" ``` -------------------------------- ### Tileserver GL config.json Structure Source: https://context7.com/maptiler/tileserver-gl/llms.txt Defines server options, style configurations, and data sources for Tileserver GL. Ensure paths are correctly set for fonts, sprites, icons, styles, and data. Supports MBTiles and PMTiles. ```json { "options": { "paths": { "root": "", "fonts": "fonts", "sprites": "sprites", "icons": "icons", "styles": "styles", "mbtiles": "data", "pmtiles": "data", "files": "public/files" }, "domains": ["tiles.example.com", "tiles2.example.com"], "allowedHosts": "tiles.example.com,localhost", "maxScaleFactor": 3, "maxSize": 2048, "minRendererPoolSizes": [8, 4, 2], "maxRendererPoolSizes": [16, 8, 4], "tileMargin": 8, "serveStaticMaps": true, "serveAllFonts": false, "serveAllStyles": false, "leafletRetina": true, "pbfAlias": "pbf", "staticAttributionText": "© OpenMapTiles © OpenStreetMap contributors", "watermark": "© My Company", "allowRemoteMarkerIcons": false, "allowInlineMarkerImages": false, "formatOptions": { "jpeg": { "quality": 85, "progressive": true }, "webp": { "quality": 90 }, "png": { "palette": true, "colors": 256 } } }, "styles": { "basic": { "style": "basic/style.json", "serve_rendered": true, "serve_data": true, "tilejson": { "format": "png", "bounds": [8.44806, 47.32023, 8.62537, 47.43468] } }, "hybrid": { "style": "https://demotiles.maplibre.org/style.json", "serve_rendered": false } }, "data": { "zurich-vector": { "mbtiles": "zurich.mbtiles" }, "terrain": { "pmtiles": "terrain.pmtiles", "encoding": "mapbox", "tileSize": 512 }, "remote-s3": { "pmtiles": "s3://prod-bucket/world.pmtiles", "s3Profile": "production", "s3Region": "eu-central-1", "requestPayer": false }, "custom-endpoint": { "pmtiles": "s3://storage.example.com/my-bucket/tiles.pmtiles", "s3UrlFormat": "custom", "sparse": false } } } ```