osbookmark.js GPX loader/exporter for Ordnance Survey Maps
Instructions:
This page links to the osbookmark.js javascript file.
- Firefox: Drag the following link to your browser’s bookmark toolbar.
Internet Explorer: right-click on the following link and “
Add to Favorites…”
This is the link:osbookmark.js
- 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 from your favourites.
Features
The script lets you:
- Display an OS map.
- Center the map on a place name.
- Choose the size of the map by adjusting the div container size.
- Import GPX tracks or routes and display as markers.
- Add markers by clicking on the map.
- Edit marker names and descriptions.
- Delete markers.
- Export markers in GPX track, route,waypoints and GPSSC route format.
- 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 this link.
http://www.stevematt.f9.co.uk/osmap/osbookmark.js
The following web sites have OS map web pages that you could use with this
script.
http://osgb.ndrw.co.uk/gpx_track/gpx_track.html?test.gpx
http://www.yorkshirewalks.org/diary06/maps/map196.htm
http://wheresthepath.googlepages.com/wheresthepath.htm note: this web site
has a high usage and may run out of map tiles so consider using another.
http://www.kap.toadstone.com/kapbook/osmap.html
http://monkeyspoon.com/tracks#osmap You will need to set the div size on this page.
http://www.electricchili.co.uk/test-map.htm?f=Ordie001.xml
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
- Allow the map web page to fully load before starting the script.
- The script was written for IE8 in other browsers it may have limited
functionality. It works ok in Opera and Firefox.
- 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.
- 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.
- 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.
- When entering a place to search for only enter the town name. OS do not
use county names or countries.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- You use the script entirely at your own risk. It is only tested in a
limited way and bugs and inaccuracies may exist.
- 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.
If you want a Google Map version of this web page then click
...Here...
Links to other things on my web site
A utility to fix USB GPS jumping mouse problems.
http://www.stevematt.f9.co.uk/FixSerial/fixserial.htm
GPSSC Laptop safety camera detector software.
http://www.stevematt.f9.co.uk/ukspeedcamera/gpssc.html
A Microsoft Silverlight3 SRTM HGT file viewer (shuttle radio topography
mission).
http://www.stevematt.f9.co.uk/sl/srtmviewer.html
Last updated 20-July-2009