Using Our Tile Server
Our tile server at tiles.the-hug.net
will serve you tiles for your mapping application via either HTTP or HTTPS if you are authorised to use it (if you're not but you would like to then contact us for a quote).
Prerequisites
- a JavaScript mapping application using OpenLayers 2, or Leaflet 1.0.3 (or later);
- server side scripting.
Authorising the User's Browser
Before your user's browser can get tiles from our tile server it needs to be authorised. You do this by sending an HTTPS request from your server (not the user's browser) to our server formatted thus:
If your user's browser is not authorised it returns a file containing:
var hugTiles = false;
However if your user's browser is authorised, which it will normally be, it returns a file containing:
var hugTiles = true; var hugKey = '<unique string of characters>';
You must include this JavaScript in the code you pass back to the user's browser as hugKey
is used for authentication with our server.
You should be able to use this from any reasonable scripting language e.g. python or perl but here's how we use it from PHP. When the user loads our mapping app at http://waymaps.the-hug.net our PHP script includes this code fragment before any other JavaScript:
Doing it this way means you get the boolean hugTiles
set in JavaScript which you can query in our code to see if you have access to the server (see also our example).
Note that this assumes that file_get_contents()
allows the reading of URLs as well as local files. This is often disabled on web servers so you may prefer to use PHP's cURL functions to authorise the browser. This has the advantage of being able to be done asynchronously and copes better with timeouts.
Making your Application use our Server
Once you've got authorisation in place you then need to set up your application correctly. Here's how to do so for:
Ireland
Our tile server includes tiles for the whole of Ireland. You can find details of how to use that here.