Magnetic declination in JavaScript / Google Maps

In the context of a Javascript Google Map application, the best way to get magnetic declination for a particular Lat / Lon?

  • There seems to be no simple algorithm for JS, or am I mistaken?
  • Is there a way using the Google Maps API to determine this, I did not find one ...
  • Web service that you can use. I found WebSites but not API.
  • Also see here , there they use the JavaScript class for this (see comment)
+6
source share
4 answers

They tricked it. To map Google maps to a source, see: -

http://www.bdcc.co.uk/Gmaps/Services.htm

+2
source

Here is an example in Javascript / jQuery that retrieves the magnetic declination for a specific lat / lon position from http://www.ngdc.noaa.gov .

declination=0; function setdecl(v){ console.log("declination found: "+v); declination=v; } function lookupMag(lat, lon) { var url= "http://www.ngdc.noaa.gov/geomag-web/calculators/calculateIgrfgrid?lat1="+lat+"&lat2="+lat+"&lon1="+lon+"&lon2="+lon+ "&latStepSize=0.1&lonStepSize=0.1&magneticComponent=d&resultFormat=xml"; $.get(url, function(xml, status){ setdecl( $(xml).find('declination').text()); }); } lookupMag(55.58552,12.1313); 

For some reason, they use internal redirects to an HTTP server, so you cannot use this from a secure site like JSFiddle , but it worked on codepen.io a couple of hours ago.

+2
source

We recently had the same issue and developed a RESTful API for the World Magnetic Model. It contains the original WMM2015v2 code, is open and available here for everyone who needs it:

https://globalmagnet.amentum.space

0
source

Source: https://habr.com/ru/post/892437/


All Articles