osbookmark.js GPX loader/exporter for Ordnance Survey Maps


Setting up a bookmark for the osbookmark.js JavaScript file.
  1. Firefox: Drag the following link to your browser’s bookmark toolbar.
    Internet Explorer: right-click on the following link and “ Add to Favorites…”
    Microsoft Edge: right-click on the following link and “ Add to reading list”
    This is the link:osbookmark.js
  2. Go to a web site that has an OS Map on it e.g. http://www.yorkshirewalks.org/diary06/maps/map196.htm and then run my script by clicking on it in your favourites or reading list.

For an alternative version that uses the Google place name search use this version of the bookmark.
Setting up a bookmark for the xpbookmark.js JavaScript file.
  1. Firefox: Drag the following link to your browser’s bookmark toolbar.
    Internet Explorer: right-click on the following link and “ Add to Favorites…”
    Microsoft Edge: right-click on the following link and “ Add to reading list”
    This is the link:xpbookmark.js
  2. Go to a web site that has an OS Map on it and then run my script by clicking on it in your favourites or reading list.

In Microsoft Edge the reading list is in favourites and is opened using the icon that is a pile of lines.

The XP version includes both a small Google map and an Ordnance Survey map. The Google map search functions are used and the results are used to center both maps. You can search for a place name, postcode or a latitude,longitude comma seperated pair. A latitude,longitude comma seperated pair looks like this '51.482252, -0.604248'. When using place names you may need to add ',uk' at the end, e.g. 'Reading, UK'. Having both maps works well.

The script lets you:

  1. Display an OS map.
  2. Center the map on a place name.
  3. Choose the size of the map by adjusting the div container size.
  4. Import GPX tracks or routes and display as markers.
  5. Add markers by clicking on the map.
  6. Edit marker names and descriptions.
  7. Delete markers.
  8. Export markers in GPX track, route,waypoints and GPSSC route format.
  9. Convert co-ordinates to/from easting,northing to longitude,latitude.

The script works by extending the functionality of a web page by adding additional JavaScript code.  In this particular case it tries to replace the browser display of the web page contents with new contents generated by the additional JavaScript.  It does not alter the original web page on it's host server.  Scripting in this way allows the API key on the original web page to be re-used to generate a new map with new functionality.

Screen shots

The script adds a dialog window to the top of the web page.  I can show some of the dialogs here but can't show any maps because of OS rights etc.





Adding to Favorites in Internet Explorer

IE might issue a warning that the bookmark on this page could be a security risk.  This is because a malicious script might be able to access the original web pages host server in undesirable ways or maliciously extract info that you enter on the original web page.  This script does not contain any malicious code but scripts from other sources might. Therefore care should be taken when bookmarking and running scripts to make sure they are not malicious.  If you understand JavaScript a good way to do this is to  manually check the JavaScript by looking at it's contents. As a general rule bookmarklets are safe on a web site where you do not enter any personal information or create emails. This type of bookmark is known as a bookmarklet for more general information see the two links below.


If you want to look at the JavaScript use these links.




The following web sites have OS map web pages that you could use with this script. 



http://wtp2.appspot.com/wheresthepath_old.htm note: this web site has a high usage and may run out of map tiles so consider using another.






http://www.pooleharbourheritageproject.org/media/harbourmap.html You will need to set the div size on this page.

http://www.secret-bases.co.uk/google-earth.htm Use xpbookmark.js with this website.


Technical overview

Any web page that has an Ordnance Survey OpenSpace map on it has an API key in it's JavaScript.  The OS OpenSpace API matches the key against the web page URL.  If they match then your browser can fetch map tiles from the OS map server.  See the OS web site for more information on OS OpenSpace.

The script will work with most OS OpenSpace web sites but not all.  You may find that some web sites are faulty and do not display the OS map because their JavaScript is not suitable for your browser.  In that case the script may still display the map ok because it uses it's own JavaScript.  So even if the original web site does not display the OS map it is still worth trying this script.  The script will not work with web pages that do not contain an OS OpenSpace API key e.g. those that contain GetAMap maps or jpg images of maps. 

Using the script

  1. Allow the map web page to fully load before starting the script. 
  2. The script was written for IE8 in other browsers it may have limited functionality.  It works ok in Opera and Firefox.
  3. The script windows are effected by the CSS (Cascading style sheets) code in the original web page.  This can cause variations in the font sizes or text positions.  You may want to experiment with various web sites and browsers to find which one works best for you.
  4. The mouse left click for deleting markers has strange effects on the left click drop down selector in IE8.  If clicking the drop down selector does not register try using your up/down keys to select the row.  Other browsers do not have this problem.  This is likely caused by the way the OS API handles browser events.
  5. The drop down menus only let you select an option once.  If you want to select the same option twice you can't.  You must select another option first.  This is how browser drop downs work. 
  6. When entering a place to search for only enter the town name.  OS do not use county names or countries.
  7. When using the 32 Shrink control window option the window is reduced to a very small window in the top left corner.  To restore the window click on it.  30 Print is similar but you might not be able to restore the window so export and save any markers before using this.
  8. The 31 'map' div size" option has no size restrictions on it so if you want to set the div size to 300% you can and this will give you a very big map.  Your browser will however struggle with maps of that size.
  9. All latitude and longitudes displayed and exported/imported by the script are WGS84 and not OSGB36 as you might expect with an OS map.  There is a difference of about 100 metres between the two standards.
  10. Be kind to the web sites that you use the script with.  If you find their tile usage is high do a Google search for another site and use that instead.  There are currently only a few sites that use the OS Openspace maps but many of these sites seem to have low usage.
  11. The Convert Longitude to Easting conversion uses the OS API for calculation so you normally need to have a map loaded for this to work.  IE8 seems able to use cached files for this so might work offline too.
  12.  Please refer to and meet any conditions of web sites that you use the script with.  As far as I know there are no conditions that apply specifically to using bookmarklets scripts but that may change in the future.
  13. You use the script entirely at your own risk.  It is only tested in a limited way and bugs and inaccuracies may exist.
  14. The script as a whole is copyright of Steve Matthews. However much of it is generic JavaScript and you are welcome to copy parts of it and re-use them in your own scripts. 


The following web sites have OS map web pages that you can NOT use with this script.  

These might be of interest to you for their Ordnance Survey map content.


Links to other things on my web site

If you want a Google Map version of this web page then click ...Here...

A utility to fix USB GPS jumping mouse problems.

GPSSC Laptop safety camera detector software.   

A Microsoft Silverlight3 SRTM HGT file viewer (shuttle radio topography mission).


Last updated 02 June 2017