practiced the followings: • VT consumption in GIS tools like QGIS. • Simple VT tile styling. • VT hosting as static file. • VT data conversion. • Simple conversion • Advanced conversion with nodejs • Vector tile hosting Today’s content: • Styling using hocon One of the good points of vector tile map is to be able to make various style maps from a single source. Let’s learn efficient way of styling.
will be able to make style.json using HOCON-parser. Let’s try making various maps with different styles from the same source. Produce Host Style Optimize Import UNVT workflow of developing vector tile for base map Supported by UNVT, open source scripts Source DB Web APP Users Our focus today.
information How can we add style information to the vector tile map? mapbox-gl.js take map styles that conform to the Mapbox Style Specification. For detail, go to: https://docs.mapbox.com/mapbox-gl-js/style-spec/ (Other map libraries also follows main part of that specification.) • A “style.json” • is a JSON object • with specific root level and nested properties • How we can make it? • By manual writing using text editor (it is tough work though…) • Mapbox Studio • Maputnik (an open source visual editor for mapbox style spec.) • UN Vector Tile Toolkit (e.g. naru with HOCON) Today, we will use unvt/nanban.
version: Style specification number. Must be 8. (required) • source: Data source. (required) • glyphs: A URL for glyphs (text font, etc). (optional) • sprite: A base URL for the sprite image (map symbols). (optional) • layers: Layers drawn in the order of this array. (required) • center: Default map center (optional) • zoom: default zoom level (optional) Source and layers are important parts. From https://docs.mapbox.com/mapbox-gl-js/style-spec/root/ (Review of previous workshop/exercise) Styling - Main components of a style.json
Teams channel. Or download it at https://github.com/unvt/ezPrac (ex5-data) * mbtiles is not included in GitHub repository • Start command prompt (I used Windows Powershell), and move to the working directory. Zipped file here
is already uploaded to the web, you can just skip this process. Here, we will establish a local server to host the vector tile. (Refer to the day 4.) Please copy clearmap-test.mbtiles from MS Teams channel in mbtiles directory if you clone the repository from GitHub. At the working directory, run: > Docker run -it --rm -v ${PWD}:/data -p 8836:8836 unvt/nanban > cd /data > npm install > npm install sqlite3 > node app.js Keep running during the practice. (You can stop it by ctrl+c) We will use port 8836 to establish a local server. Please use another port if you already use it.
CLI. Go to the working directory, and start docker. > docker run -it --rm -v ${PWD}:/data unvt/nanban > cd /data • Try “rake” to obtain a new style.json in htdocs directory. > rake By running rake, we are making style.json from files in hocon folder (hocon/style.conf, etc.). Tips: You do not have to specify the port this time.
kind of the primary file for the style editing. It includes information on “version,” and several components (_root, sources, layers, metadata) which are described in the different files. Now you do not have to change them. Please just confirm. Let’s see what is in the hocon folder
several elements in the style.json. • “sprite” is the location of the map symbol, etc. • “glyphs” is the location of the text fonts. Use # to make some comments Now you do not have to change them. But you can try changing the center and/or zoom if you want. Let’s see what is in the hocon folder
the source. • You can freely name the source name (we are using “v” now). • You can add more than one source. Now you do not have to change them. But you can try changing max/min of the zoom level if you want. Let’s see what is in the hocon folder
list of layers. • You can add layers, but please make sure that you prepare config files for these layers. • For example, you may find there are “background.conf,” “pg-landmass.conf,” and so forth. • Practice: Please try to delete # in the line 10, 11, 12 to add some symbols. Let’s see what is in the hocon folder
From easy one to complicated one. • You will be familiar with them once you practice. Practice: For example… • Change the color of the ocean and/or landmass • Change the width of the coastline • Change the minimum zoom of the ocean label (pt-lab-water-ocean.conf) Etc… Let’s see what is in the hocon folder
ready, run the following command again. You will get new style.json > rake Check the map to see if there is any change! • http://localhost:8836/sample-map.html style: http://localhost:8836/style.json
dark” to obtain “clearmap-plain.json” and “clearmap-dark.json”. They are developed from the files in “hocon-plain” and “hocon-dark” respectively. Check Rakefile to see the script.
UNVT workflow of developing vector tile for base map Supported by UNVT, open source scripts Source DB Web APP Users • Thank you for your interest and participation. • I hope you understood some detail about the vector tile in these exercises. • Any feedback will be appreciated.