OS Map - Custom Server

Setting a Custom Server for OS Map

The map data for OS Map is gathered using the freely available OpenSpace API.  If you wish to experiment with the map content shown (or use OS Map on any OpenLayers page), you can point the application to a custom server.  This has the added advantage of not relying on the PocketGamer web server.  Fortunately, this is extremely easy to do, and completely free.

 

Step One - Register a Free Website (skip if necessary)

If you don't have access to free webspace through either your ISP, or one of the many free hosting companies on the net, I can recommend 000webhost.com.  I don't have any connection with them, but I did test out this tutorial on one of their free accounts.  

What you need to take away from this is the web address that corresponds to your website.  It will probably be in the format http://mysite.webhost.com or http://www.webhost.com/mysite/.  This address is needed for two reasons - to register for an OpenSpace API key, and to put into the OS Map software.

 

Step Two - Register for your OpenSpace API key

Visit the OpenSpace website and click on "Register for your API key".  Only the bare minimum needs to be filled in here - name, email, and crucially, the web address that we registered in Step 1.  Agree to the Developer Terms and Conditions, and click Register.

You will shortly receive an email containing an API key, in the format XXXXXXXXXXXXXXXXXXXXXXXXXX.  Select the key, right click on it, and choose "Copy".

 

Step Three - Add your key and upload the HTML page

Download the server HTML source code, and extract it from the ZIP file.  Macs usually do this automatically, Windows users will need to right click on the file and choose "Extract All".  Typically, you'll find the downloaded file either on your Desktop or in your Downloads folder.

Now we need to edit the file to add our personal key.  Right-click on getmap.htm, and choose "Open With", and then Notepad for Windows users, or TextEdit for Mac users.  

IMPORTANT: If you open the file with TextEdit on a Mac, it is essential that you tick the box marked "Ignore Rich Text Commands".  If you don't do this, you'll only see a blank page.  

Look for a line like this (I've abbreviated part of it here for clarity):

 

<SCRIPT type="text/javascript" src="http:// .... openspace.js?key=XXXXXXXXXXXXXXXXXXXXXXXXXX">

 

Now select all the X's in the line (making sure not to select the equals sign next to them, or the quotation mark at the end), and paste in your own key.  You should be able to select just the key by double-clicking on it.  Save the file.

You now need to upload the file to your webspace.  Using FTP clients is beyond the scope of this guide, but if you're sticking with 000webhost.com, then you won't need one.  In the Members Area, click the link to open the Web File Manager.  In the new window that opens, click on the folder called "public_html".  This is the folder we need to put the getmap.htm file in.  Click "upload", navigate to your getmap.htm file, and then click the green tick.  

 

Step Four - Enable the new server in OS Map  

Open OS Map on your Android phone, and wait for it to finish loading the map.  Push the menu button, then "Preferences".  Scroll down the list until you come to Server Settings.  

Turn on "Use Custom URL", and then enter the web address from Step One in the Custom URL box underneath, remembering to add "http://".  Tap the "back" button to leave the preferences page.  

Important: Make sure that you do not add "/getmap.htm" or "/" to the end of the URL.  

Restart the OS Map application.  The best way to do this is to push the "home" button, and then relaunch OS Map from the applications list. If things are working properly, you should see the map load as normal.

 

That's it!  

If you're at all unsure about modifying your getmap.htm file, please don't hesitate to get in touch with me and I'll do my best to help you out.