• Stars
    star
    145
  • Rank 254,144 (Top 6 %)
  • Language CartoCSS
  • Created about 9 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vector tiles sample MBTiles file with PBF's made by mapnik via MapBox Studio

Custom vector tiles from Georaphy Class example made with MapBox Studio / TileMill2

This repo documents results of tests on vector tiles as defined by MapBox and shows various variants of usage of these tiles on your own server.

Results: screen shot 2015-09-26 at 23 43 45

The repo contains two MapBox Studio Classic projects: data source (.tm2source) and style (.tm2) necessary to create custom vector tiles (protobuf encoded MVT - MapBox Vector Tiles) packed in MBTiles and shows what can be done with such tiles. Both these projects contain the Mapnik's XML style usable with any mapnik-powered software, if mapnik is compiled together with mapnik-vector-tiles.

The look&feel of this sample is a port of GeographyClass example from Tilemill into TileMill2 aka MapBox Studio Classic. It uses vector data (.shp) from NaturalEarthData.com, originally distributed by MapBox with the open-source TileMill project for use in the Geography Class example: https://github.com/mapbox/tilemill/tree/master/examples/geography-class

Work with MapBox Studio Classic

  • Clone this repo or download the files to you computer.
  • Start MapBox Studio (https://www.mapbox.com/mapbox-studio/)
  • Click on Projects -> Browse and add the two projects
  • Play with the styles in CartoCSS when the style project is openned
  • Click on Layers -> Change source and assing your own local copy of Countries.tm2source from your disk

Create vector MBTiles (with pbf inside)

  • Open under "Sources" the source project Countries
  • Check the layers on the right side and their definition. Feel free to add another shapefiles or Postgres requests.
  • Click on "Settings" and "Export to MBTiles"

You will get a file with extension .mbtiles, which contains "pbf" vector tiles. Such sample file can be also directly downloaded as countries.mbtiles

Host the vector tiles on your own server

It is easy to host the vector tiles on MapBox service, but if you want it on your own server is straightforward as well by installing Tileserver-PHP project. If you a have an Apache+PHP hosting - just unpack the project files and drop the MBTiles with vector (or raster) tiles in the same directory. See this video tutorial: https://youtu.be/F6MvDvc5m-I?list=PLGHe6Moaz52PiQd1mO-S9QrCjqSn1v-ay

Alternativelly you could also start the TileServer-PHP on your laptop with docker. The ready to use container is on DockerHub. Under Mac OS X and Windows docker is extremely easy to use with the Kitematic graphical user interface: https://kitematic.com/ In Kitematic just search for "tileserver" and start the virtual machine with the project inside by clicking on "Start". Then click on "Volumes" and drop into the folder your MBTiles files - and you get a running hosting for your vector tiles.

Load the tiles into MapBox Studio from your server

MapBox Studio project with styles can load the vector tiles from your own server, if you provide URL to the TileJSON (linked from bottom of the sidebar in TileServer.php viewer of each layer). (Note: in MapBox Studio 0.2.7 is a bug #1288 with "Invalid URL", fixed in the master so probably fixed 0.2.8+).

There must be correct CORS headers on your server - but TileServer-PHP project ensures everything is fine out of the box.

Host the vector tiles without any server at all

The vector tiles can be unpacked from MBTiles (SQLite) container and hosted just a in direct folder structure - the same way as raster tiles are typically made with a software like MapTiler or GDAL2Tiles. The demonstration of such approach is visible at http://klokantech.github.io/mapbox-gl-js-offline-example/.

To unpack and ungzip the tiles I have used mb-util:

./mb-util --image_format=pbf countries.mbtiles countries
gzip -d -r -S .pbf *
find . -type f -exec mv '{}' '{}'.pbf \;

Display the vector tiles directly with MapBox GL JS

I have prepared a sample viewer with local copy of MapBox GL JS and custom tiles hosted as static files in here:

http://klokantech.github.io/mapbox-gl-js-offline-example/

The styling must be done in a JSON format manually - and is not exportable from MapBox Studio (yet). Because of WebGL browser security restrictions, the tiles must be hosted in the same domain or you have to ensure CORS are set. BTW GitHub Pages used for hosting above does not support CORS headers unfortunatelly, but the rawgit CDN does support CORS.

For more details see: https://github.com/klokantech/mapbox-gl-js-offline-example

Generate standard raster MBTiles with PNG / JPEG from MapBox Studio

MapBox Studio does not offer export of the standard raster tiles, but it does contain mapnik which runs on localhost - for users to preview the map style on desktop. This server is exposed also outside of the app #1024. It means a basic program can request the raster tiles in a batch and save these into MBTiles format. If you start MapBox Studio - you can View -> Toggle Developer Tools and check Network request to the tiles you see in the project you edit.

Then a utility like tilecloud can be started on command line to request all tiles at given resolution and save these into raster MBTiles format.

$ ./tc-copy -v -o -b 0/0/0:6/*/* "http://localhost:3000/style/%(z)d/%(x)d/%(y)d.png?id=tmstyle:///Users/klokan/Documents/MapBox/project/countries.tm2" countries-raster.mbtiles

The sample of the raster MBTiles tiles is in this repository as well - and hosted at https://github.com/klokantech/vector-tiles-sample/releases/download/v1.0/countries-raster.mbtiles and exported into static files for online preview at http://klokantech.github.io/vector-tiles-sample/

More Repositories

1

mapbox-gl-js-offline-example

Sample vector tiles displayed with local copy of MapBox GL JS
HTML
235
star
2

flask-firebase

Google Firebase integration for Flask
Python
104
star
3

roman-empire

Map of the Roman Empire made with vector tiles
HTML
80
star
4

osmnames-sphinxsearch

Geocoder search engine for OSMNames.org data powered by sphinx search
Python
77
star
5

pdfium

PDFium library without V8 JavaScript engine - compiles under Linux, Mac and Windows
C++
54
star
6

iiifviewer

[DEPRECATED] IIIF WebGL / Canvas / DOM mobile-ready fast viewer powered by OpenLayers V3
JavaScript
54
star
7

klokantech-gl-fonts

Merged Google Noto fonts to provide glyphs for unicode OpenStreetMap labels in TileServer-GL
53
star
8

github-time-tracking

Add time tracking to the GitHub Issue Tracker with Harvest Platform.
JavaScript
52
star
9

openmaptiles-language

Javascript library for changing language of OpenMapTiles map in mapbox-gl-js
JavaScript
23
star
10

tileserver-gl-styles

Prebuilt map styles in GL JSON format for use in the TileServerGL and OpenMapTiles
18
star
11

jekylledit

Jekyll Visual Content Editor for Customers - WYSIWYG web administration / CMS for GitHub Pages website
JavaScript
17
star
12

embedr

Embedr.eu - Image Embedding Service (IES) with support for IIIF, OEmbed, zoomable viewer in an iFrame
Python
15
star
13

Apple-WWDC10-TileMap

Apple official iOS demo app for displaying gdal2tiles / MapTiler maps presented at WWDC 2010
Objective-C
15
star
14

osm-vector-cordova

OpenStreetMap vector tiles with native MapBox GL and Apache Cordova / PhoneGap Build
HTML
12
star
15

gl-style-package-spec

Best practice for storing "GL Styles" in a repo / directory / zip package
JavaScript
10
star
16

facebook-openid

Facebook OpenID Provider - allows to log in with Facebook account into any OpenID service, including Google AppEngine Federated Login
Python
10
star
17

omeka-plugin-IIIF

Omeka plugin for IIIF image service: used for thumbnails & zoomable viewer. Omeka also serves IIIF Presentation API manifest for use in Mirador or other tools.
PHP
9
star
18

tileserver-gl-data

DEPRECATED - Sample data and config for tileserver-gl
9
star
19

maptiler-ios-start

MapTiler iOS Start
Objective-C
8
star
20

cloudwrapper

Cloudwrapper - job queue, logging & metrics for Amazon, Google and private cloud
Python
6
star
21

bombard-docker

5
star
22

flask-backend

Asynchronous backend tasks for Flask
Python
5
star
23

postgres-docker

Docker image derived from official library image with PostGIS and pgcrypto extensions installed.
4
star
24

arcgis-js-vector-tiles-vtpk

Sample vector tile package generated by ArcGIS Pro
4
star
25

tippecanoe-docker

TippeCanoe on DockerHub
4
star
26

gdal_georeferencer

Creates GeoTIFF from a local image and metadata from Georeferencer.com online service
Python
4
star
27

omeka-s-docker

ApacheConf
4
star
28

omeka-docker

Classic omeka in docker
ApacheConf
4
star
29

supervisord-docker

Supervisord Docker
3
star
30

jpeg-opencl

Automatically exported from code.google.com/p/jpeg-opencl
C
3
star
31

cynefin

Cynefin Project
CSS
3
star
32

tilejson-ol3

OpenLayers implementation of TileJSON with custom projections
HTML
3
star
33

osm2vectortiles-ios-helloworld

Native iOS mobile application showing OSM2VectorTiles mapping data on iPad / iPhone
Objective-C
3
star
34

javascript

KlokanTech Standard JavaScript Library (JS)
JavaScript
3
star
35

sheets-preview

Offline spreadsheet preview Chrome App. Open binary files like XLS, XLSX, ODS (OpenOffice) directly with this JavaScript app, make basic editing and copy&paste to Google Sheets / Docs or a desktop software.
JavaScript
3
star
36

klokantech-gl-styles

Visual style for Klokantech Maps (GL JSON)
2
star
37

flask-fastspring

FastSpring API integration for Flask
Python
2
star
38

gdaldem_web

C
2
star
39

omeka-s-module-IIIFHosting

PHP
2
star
40

styles

KlokanTech Standard Style Library (CSS)
HTML
2
star
41

dare-raster-tiles

Digital Atlas of the Roman Empire - hosted raster tiles for use in vector map
HTML
2
star
42

proj4gl

Proj4GL is a GLSL shader code library for transforming point coordinates from one coordinate system to another, including datum transformations. This library is a port of popular PROJ.4 library to the shading language usable in both JavaScript and C/C++.
2
star
43

data.epsg.io

The regularly updated EPSG database available as OKNF DataPackage to track versions and exported as SQLite
1
star
44

nlsgb1900

NLS GB1900 gazetteer https://klokantech.github.io/nlsgb1900/
HTML
1
star
45

www.iiifhosting.com

Web of IIIF hosting
HTML
1
star
46

thumbnail-gl

Shell
1
star
47

dpkg-buildpackage-docker

Docker image for Debian dpkg-buildpackage with Python support - to create a .deb from python package
Python
1
star
48

nginx-docker

Nginx docker
Shell
1
star
49

bmarchives-tickets

BMArchives Request/Issue Tickets Tracker
1
star
50

flask-cron

Periodic task execution for Flask
Python
1
star
51

flask-mailgun

Mailgun integration for Flask
Python
1
star
52

search

Fulltext search service with JSON API implemented on top of SphinxSearch - to index Jekyll websites
Python
1
star
53

cdn.klokantech.com

KlokanTech CDN
JavaScript
1
star
54

pastplace

PastPlace responsive website design
HTML
1
star
55

proftpd-docker

ApacheConf
1
star
56

OS-Open-Zoomstack-Stylesheets

Cartographic stylesheets for OS Open Zoomstack
QML
1
star
57

scroll-story-map

Storytelling with a moving map while scrolling a page with text and photos
1
star
58

plugin-PDFOutput

The Omeka plugin providing PDF output format for item detail page /items/show?output=pdf
PHP
1
star
59

nls.tileserver.com

Static files on the free NLS API hosting
JavaScript
1
star