Phonegap with Compass and GPS coordinates

前端 未结 1 1470
-上瘾入骨i
-上瘾入骨i 2021-02-01 11:32

I am working on a project that takes the compass script from Phonegap and i would like to connect it to my currect GPS position and than point to a fixed GPS position (like a re

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 11:51

    The following code basically does what you want. It calculates the distance and bearing from your current location (by GPS) to a destination position and uses the compass to determine your current heading. The difference between your current heading and the bearing to the destination is the angle for your arrow.

    The code with assets and compiled Android APK can be downloaded from here: http://ge.tt/4Kb2oQv/v/0

    Here's the code, hope it helps!

    
    
    
        
        
        Compass test
    
         
         
         
    
    
        
    
        
    
    
        

    Distance to destination: metres

    Bearing to destination: degrees

    Current heading: degrees

    Difference in heading and bearing: degrees

    Destination

    0 讨论(0)
提交回复
热议问题