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

  • Home
  • SEARCH
  • 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 6345535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:50:30+00:00 2026-05-24T20:50:30+00:00

I got the below code from @DanS at this link how-to-display-a-map-still-image-file-with-a-moving-current-location onCurrentPosition(Location current){ double

  • 0

I got the below code from @DanS at this link how-to-display-a-map-still-image-file-with-a-moving-current-location

onCurrentPosition(Location current){
    double hypotenuse = upperLeft.distanceTo(current);
    double bearing = upperLeft.bearingTo(current);
    double currentDistanceX = Math.cos(bearing) * hypotenuse;
    //                     "percentage to mark the position"
    double currentPixelX = (currentDistanceX / upperLeft.distanceTo(lowerRight) * Math.cos(upperLeft.bearingTo(lowerRight))) * mapWidth;

    moveIndicatorX(currentPixelX);
}

Here are the values:

  • current: 41.850033,-87.65005229999997
  • upperLeft: 41.866514127810355,-87.6720142364502
  • lowerRight: 41.83397145565242,-87.62824058532715
  • mapWidth: 512 x 512 px

Here are the calculator online for Location, hypotenuse(Distance), bearing(Azimuths)

  • convert LatLng to Location format(e.g. 41° 51′ 59.45″ N 87° 40′ 19.25″ W)
  • compute distance & azimuths from the given Location

I got the results of:

  • hypotenuse = 2581
  • bearing = 135.21
  • currentDistanceX = -2562
  • currentPixelX = 311.9

Would like to ask you guys to:

  1. to confirm if my computed results are correct.
  2. on how to compute the currentPixelY (the another one point)?

By the way, I am planning to use that to compute the location of a given real life LatLng(current) against with my still image map which bonded the upperLeft and lowerRight corners of the still image into real life LatLng.

If you want to see the actual & expected output and want to easily understand the whole picture. Please refer to this link -> How to mark the current location into a still image map

  • 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-24T20:50:31+00:00Added an answer on May 24, 2026 at 8:50 pm

    This is the actual code I’m using, not pseudo code posted previously:

    Location upperLeft = new Location("");
    upperLeft.setLatitude(41.866514127810355);
    upperLeft.setLongitude(-87.6720142364502);
    Location lowerRight = new Location("");
    lowerRight.setLatitude(41.83397145565242);
    lowerRight.setLongitude(-87.62824058532715);
    Location current = new Location("");
    current.setLatitude(41.850033);
    current.setLongitude(-87.65005229999997);
    double hypotenuse = upperLeft.distanceTo(current);
    double bearing = upperLeft.bearingTo(current);
    double currentDistanceX = Math.cos(bearing * Math.PI / 180.0) * hypotenuse;
    //                     "percentage to mark the position"
    double totalHypotenuse = upperLeft.distanceTo(lowerRight);
    double totalDistanceX = totalHypotenuse * Math.cos(upperLeft.bearingTo(lowerRight) * Math.PI / 180.0);
    double currentPixelX = currentDistanceX / totalDistanceX * 512;
    
    System.out.println(currentPixelX); // 259.3345493341548
    

    Your calculated answer looks a bit off.
    To calculate Y change copy all the X marked calculations and variables to use Math.sin() instead of Math.cos().

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

Sidebar

Related Questions

No related questions found

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.