With BGS consent, I have put a thin JSON/REST Web Service Wrapper
around

http://www.geomag.bgs.ac.uk/gifs/gma_calc.html

My wrapper URL looks like this

http://magcalc.appspot.com/?e=329000&n=123456&m=b.chad+at+host.com&id=c1&callback=fred

When using this service PLEASE give a sensible escaped email address
of yours as parameter m - this is for BGS logging. Parameters e and n
are UK grid eastings and northings in metres and callback is the name
of your JS function to call when the load has completed. id is an
optional tag parameter that will be put in you JSON object as its "id"
property.

To call (asynchronously) from java script use something like

function getMagAngle(e, n, id)
{
var script = document.createElement("script");
script.setAttribute("src", "http://magcalc.appspot.com/?e="; +
parseInt(e) + "&n=" + parseInt(n) + "&m=your.email+at+goes.here" +
"&id=" + id + "&callback=gotMA");
script.setAttribute("id", "jsonMagAngleScript");
script.setAttribute("type", "text/javascript");
document.documentElement.firstChild.appendChild(script);
}

The callback would look something like this.

function gotMA(d)
{
if(d){
if(d.angle)
alert(d.angle);
}
}

Here is a typical return

fred({"id":"m1","east":329000,"north":123,"angle":
2.02,"ordinal":"W","date":"July 2008"});

angle is in decimal degrees (precision 1/60) east or west of grid
north, according to ordinal (which will be E or W), at east and north
as supplied in the call.


If you want to use Lat+Lon not East+North you will have to convert
using one of the several javascript libraries available.

Has any one come across a javascript or Python version of the USGS
World Magnetic Model C Code?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to