Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4532244
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:00:19+00:00 2026-05-21T14:00:19+00:00

I have a MapView in which I am drawing buildings on using geopoints. Currently,

  • 0

I have a MapView in which I am drawing buildings on using geopoints. Currently, the app determines the closest building to you by just checking your long/lat and comparing to the buildings; but what I want to be able to do is point my device at a building and have that buildings info pop up, even if it isn’t the closest building to you.

I have looked up how to accomplish this and I would be using the azimuth direction received from the ORIENTATION sensor listener. I am having trouble using that azimuth direction and determining if it is intercepting one of the buildings on the map.

Would I be using the ORIENTATION sensor and azimuth to accomplish this? How would I go about implementing this? Any help appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:00:20+00:00Added an answer on May 21, 2026 at 2:00 pm

    Figured out the solution:

    I used this function(and helper function) to get the bearing from my current location to the closest buildings around me(using a set radius):

    public static float calculateBearing(GeoPoint before, GeoPoint after) {
        Point pBefore = location2Point(before);
        Point pAfter = location2Point(after);
    
        float res = -(float) (Math.atan2(pAfter.y - pBefore.y, pAfter.x
                - pBefore.x) * 180 / Math.PI) + 90.0f;
        if (res < 0)
            return res + 360.0f;
        else
            return res;
    }
    
    public static Point location2Point(GeoPoint aLocation) {
        return new Point((int) (aLocation.getLongitudeE6()),
                (int) (aLocation.getLatitudeE6()));
    }
    

    Once you have the bearings of the buildings around you; you must then compare that to the bearing your phone is positioned at using a SensorEventListener for the TYPE_ORIENTATION sensor to find out which of the closest buildings your pointing at.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app on the android market, which uses the mapview to display
I am currently using osmdroid jar 3.0.1, and I have a MapView inside a
I have an app which is using CLLocationManager in background and in foreground Mapkit
I have a mapview class which extends MapActivity. The code i'm using follows the
I am building a Tab Bar App and have a MapView set up on
I have an Android MapView in which i need to have a second layer
My application uses a MapView which will display multiple places. I have the latitude
I have a mapview with several annotations. Every annotation has a leftCalloutAccessoryView which is
I have a FrameLayout view which contains one (MapView-like) control and some additional buttons
I am working on a Mapview in my android application, in which i have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.