Saturday, 8 February 2014

Using different map tile servers with leaflet.js

The following post is a portion of the Leaflet Tips and Tricks book which is free to download. To use this post in context, consider it with the others in this blog or just download the the book as a pdf / epub or mobi .
----------------------------------------------------------

A tile server is a source of the tiles that leaflet.js uses to present a map. Because there are many unique requirements for maps there are a large number of variations of tile servers that apply different formatting and styling to the geographic information.
In this chapter we will present the different services available and the different requirements for use in terms of the URL template, terms of use and attribution where appropriate.

URL Template

The URL template is the format required when specifying the link to the tiles on the server. Typically this will be in the form of a server name (which may have sub-domains) followed by the zoom level and then x/y values for the tiles. For example, the following is the URL template for the standard OSM server.
http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
The http://{s}.tile.openstreetmap.org is the server name with the {s} part representing a variation in possible sub-domains. {z} is the zoom level and {x}/{y} is the tile location.

Usage Policy

Because there is an overhead involved in generating and providing tiles to make maps with, it is expected (and entirely reasonable) that providers will have a usage policy to avoid placing an undue strain on their equipment and bandwidth.

Attribution

Attribution is about providing credit where credit is due and acknowledging the copyright of the originator of a work. It is significant effort to style and produce map tiles and that should be recognised and noted appropriately. Typically this would be in the form of a note in the bottom right hand corner of the map being presented. Some of the attribution requirements might sound a little formal, but they need to be that way so that their message is clear in a legal sense. To ordinary people, we need to recognise that we are using a work created by someone else and that we make sure we recognise that appropriately :-).

Examples

I will post separate examples of the usage of different tile servers as separate posts. Or you can find them all in Leaflet Tips and Tricks.

The description above (and heaps of other stuff) is in the Leaflet Tips and Tricks book that can be downloaded for free (or donate if you really want to :-)).

No comments:

Post a Comment