TileServer GL is an open-source tool for serving MBTiles and other tilesets via vector tiles. It is designed to be fast and efficient, making it a great choice for serving maps on the web. In this tutorial, we will go through the steps to install TileServer GL on Ubuntu Server Latest using the command line.
Before we begin, you will need:
TileServer GL is built on Node.js, so we will first install the latest version of Node.js and Git using the command line.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nodejs git
node -v
It should output the version of Node.js installed.
Now that Node.js and Git are installed, we can proceed with installing TileServer GL.
mkdir tileserver
cd tileserver
git clone https://github.com/maptiler/tileserver-gl.git
npm install
Now that TileServer GL is installed, we need to add a tileset. We'll use a sample OSM tileset in this example.
curl -o data.mbtiles https://tileserver.freemaps.io/osm-qa-tiles.mbtiles
npm start
In the browser, navigate to http://<your-server-ip>:8080/index.html
. You should see the TileServer GL web interface.
Click on the Add a Tileset
button and select the data.mbtiles
file that you just downloaded.
Click on Add Tileset
to add the OSM tileset.
Now that the tileset is added, you can access it using any client that supports vector tiles. Here's an example using OpenLayers:
index.html
with the following code:<!DOCTYPE html>
<html>
<head>
<title>TileServer GL Demo</title>
<link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/latest/build/ol.js"></script>
</head>
<body>
<div id="map" class="map"></div>
<script type="text/javascript">
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.VectorTile({
source: new ol.source.VectorTile({
format: new ol.format.MVT(),
url: 'http://<your-server-ip>:8080/data/{z}/{x}/{y}.pbf'
})
})
],
view: new ol.View({
center: [-117.168660, 32.732998],
zoom: 12
})
});
</script>
</body>
</html>
Replace <your-server-ip>
with the IP address of your Ubuntu Server Latest machine.
Save and close the file.
Open the file in your browser to view the map.
Congratulations! You've successfully installed TileServer GL on Ubuntu Server Latest and added a tileset to it. You can now serve vector tiles to any client that supports them.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!