Question

I'm building a Django site connected to an android app. The android part is a navigator, and the site permits to build your own maps using images.

During the construction of these maps, user can set the bearing through a rotation of the image of the map on an instance of google maps.

I'm using css to rotate the image, so 0° is the image "as is" and 360° is the image upside down: so the north is "up".

The android app will not use the gps system, so I have to relay on the magnetic field to show the map rotating on user's movements (for detecting the user's movement I have another method, but this is not necessary for the question), and I found out on this page that magnetic north is not that showed in google maps, and that I have to do some corrections to the values, but I don't know how.

Somebody can help me to shift the images's rotation degree to north magnetic degrees?

Was it helpful?

Solution

It sounds like you are looking for magnetic declination values. First you will need to get your location. Since you don't have GPS, you will use the NETWORK_PROVIDER location; this will be close enough to get your declination value.

To find out how far and which direction to rotate your images you should use something like this API from NOAA.

For example, if you are @ 40.000, -105.250 you would make this API call:
http://www.ngdc.noaa.gov/geomag-web/calculators/calculateDeclination?lat1=40&lon1=-105.25&resultFormat=xml

And you would get this in return:

<?xml version="1.0"?>
<maggridresult>
    <result>
        <date> 2012.82514 </date>
        <latitude> 40.00000 </latitude>
        <longitude> -105.25000 </longitude>
        <elevation units="km"> 0.00000 </elevation>
        <declination> 8.90399 </declination>
        <declination_sv> -8.01691 </declination_sv>
    </result>
</maggridresult>

So you would rotate your map 8.90399°

For reference, here is a map showing approximate magnetic declination values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top