Search code examples
androidcompass

A compass that points to a specific city


I recently started developing an app in Android Studio, the app contains a compass. Everything works for me, now I have been instructed to change the compass not to point north but to specific coordinates. for example: The arrow will point in the direction of the coordinates: 31.77682832908305, 35.234508502967

Do you have any suggestions on how to do this?


Solution

  • If the destination 's longitude is less than your current location's longitude, point the compass to left (i.e., west)
    or else right, (i.e.., east )

    if the destination 's latitude is less than your current location's latitude , point the compass to top (i.e.., north)
    or else bottom, (i.e.., south)

    have a look at https://developers.google.com/maps/documentation/urls/get-started#directions-action which gives you path- direction from source to destination and tune it up..