📜 ⬆️ ⬇️

Advanced TileMill Features



I continue the review of cartographic design studio TileMill.

Previous parts:
  1. Studio Review
  2. Introduction to TileMill

Today I will review:

Interesting? I invite under the cat.
')
Legend

As I promised, today I will show how you can expand the scope of TileMill by creating a legend and using interactivity.

Let's start by creating a legend for the map. To do this, open the project settings and go to the “Legend” tab.



Legend must contain HTML code. You can also use CSS (if you want iPad compatibility) or rely on external CSS provided by web applications.

A legend may include images, for example, icons corresponding to markers on a map. You can also use unicode symbols such as geometric shapes or box-drawing symbols along with custom colors and CSS to create lines, shapes, and points.

Here is an example of a simple legend:
  <span style='color:#F3E5BE'></span> 5  <span style='color:#EFF1A8'></span> 6  <span style='color:#EFEE8D'></span> 7  <span style='color:#DC8540'></span> 8  <span style='color:#ED4B7D'></span> 9  


And the result:



Interactivity

The release of TileMill 0.2.0 is notable for a new feature - support for interactive maps. Interactivity allows you to extract data from an attribute table and display it on a map using prompts or pop-up windows.

TileMill uses special “ grids ” to describe the interaction of data in invisible JSON tiles. Javascript and HTML are all that is needed to ensure interactivity on the map, so this method is 100% compatible with W3C standards. Using this technology, it is possible to display thousands of interactive elements on the map, without using Flash and not worrying about the speed of the application.

So, to add interactivity, open the project settings and select the "Interactivity" tab.


  1. Select the layer on which you want to maintain interactivity.
  2. Select the name of the field of the attribute table, which should be unique for all layers.
  3. Specify the format for text output. You can use HTML, CSS, and a set of tokens (see the next paragraph). By default, the teaser displays a hint when you hover the cursor, and the full format will be displayed when you click on the active element.
  4. In addition, you can use tokens that will be replaced with their attribute table data.

After saving, the card will respond to your settings.



Interactivity can be exported to the MBTiles format, which can be used on the TileStream and SaaS platform servers from the developers of the studio - TileStream Hosting.

Mbtiles




MBtiles is a specification for storing sliced ​​tiles in SQLite DBMS with the ability to instantly return. Such a data format allows you to transfer thousands, hundreds of thousands and even millions of tiles in one file.

The MBTiles upload speed is higher than the upload speed of millions of individual tiles, when booting to USB, mobile devices, or transferring over the network. The difference in speed between accessing the database or file system when using MBTiles is insignificant.

Since MBTiles use embedded SQLite DBMS, they can be used without an Internet connection.

Tiles are stored as BLOB (Binary Large OBjects - the storage format of large volumes of binary data), therefore, can be used in most SQLite clients.

Example

Download the Haiti Terrain Gray tile set. Then, open the file in the SQLite client:
 sqlite3 haiti-terrian-grey.mbtiles 

Execute the following SQL statement:
 SELECT * FROM tiles WHERE zoom_level = 5; 

You will receive all tiles with a presentation level of five.
 5|8|17|???? 5|8|18|???? 5|9|17|???? 5|9|18|???? 5|10|17|???? 5|10|18|???? 


Where ???? - presentation of PNG images in BLOB.

Compress MBTiles


The development team worked hard on MBTiles compression. They found that you can reduce the file size up to 60% while maintaining backward compatibility.



The principle of compression is simple - the 'tiles' table is replaced with a view with the same name that returns the same results.

This method is a simplified version of the sliding window compression algorithm (this algorithm underlies zip, 7zip, and many other popular formats). The result is a file that is noticeably smaller. This is especially noticeable for such vector data sets as World Light, with a large number of presentation levels.



Conclusion


That's all for today, thank you for your attention. In the next topic I will discuss the use of PostGIS in TileMill and the use of MBTiles in practice, using the TileStream tile server and various map libraries.

Useful links

  1. MBTiles - full format specification
  2. MBTiles Utils - a set of utilities for data compression

Source: https://habr.com/ru/post/122376/


All Articles