Sunday 3 October 2010

VectorMap District on OpenSpace

VectorMap District is now a layer in OpenSpace. See here for instructions on how to add it to a map. It doesn't appear by default - the default layers are listed here. For a description of all the available OpenSpace layers, including VectorMap District see here. VectorMap District appears between the 1:50K layer and the StreetView layer.

I've updated the cycle count map to include VectorMap district. Apparently VM can be configured and styled by the user but I've not found out how yet.

Incidently, with the latest version of OpenSpace, the OS have fixed the problem with Internet Explorer 8.

Friday 13 August 2010

Experiments with geoJSON and OpenSpace

I was asked recently to provide an online map of cycle count locations. The information was provided as point data using Ordnance Survey Eastings and Northings. For a change from Google Maps I decided to use the Ordnance Survey's OpenSpace mapping service.

For a further change, I decided to serve the point data to the map using geoJSON. geoJSON is a format for encoding geographic features. It is not as verbose as XML and unlike KML you can specify your co-ordinate reference system.

A further advantage of JSON in general is that it avoids the cross domain problems caused by making XMLHttpRequest calls in your JavaScript (see here for a description) i.e. where your web page is on a server in one domain and you want to call XML data from a server in another.

OpenLayers, which OpenSpace is built on, has functionality to allow the reading and parsing of geoJSON data.

The geoJSON was generated on-the-fly from data in an SQL Server table using an ASP.NET script. The data can be seen here:

http://www.gmtu.gov.uk/openspace/cycledata.aspx

Although it is less verbose than XML, geoJSON is, for me, less readable for the human eye.

The application can be seen here:

http://www.gmtu.gov.uk/openspace/cyclecount.aspx

If you look at the source code for the above page you can see that the JavaScript is fairly straightforward - read in the geoJSON data and loop through it, creating markers.

The only issue was with viewing the map in Internet Explorer 8. OpenSpace has problems with IE8, see this discussion.

Anyway a meta tag in the page head will force IE7 Compatibility mode which solves the problem.