Snips
Barry Hunter over at the Google API discussion list has pointed that my conversion routine is not wholly accurate. I am only converting OSGB “grid refs” not the full OSGB36 to latitude and longitude.
If I ever get time I will use the OS spreadsheet calcs to implement a full conversion.
I thought I might get a mention at the Open Tech conference since I use the bbc travel feed info but no such luck.
GeoPosition
I have posted up a link (look under the ‘Pages’ heading) to a javascript class I have written called GeoPosition. This will convert coordinates between OSGR and WGS84 formats. WGS84 is the format google maps uses to plot points.
Here you are.
Code fix – The function calculateZoomLevel will now set the zoom level correctly to the bounding box of the dataset points. Thanks DaveP.
function calculateZoomLevel(spanLng, spanLat)
{
var level = _zoomLevelsX.length-1;
var found = false;
var index = 0;
while (!found && index<_zoomlevelsx .length)
{
if (_zoomLevelsX[index]>spanLng && _zoomLevelsY[index]>spanLat)
{
level = index;
found = true;
}
index++;
}
return level;
}
The zoomLevelsX and Y arrays hold the span values for each of the zoom levels.