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 7972717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:56:20+00:00 2026-06-04T07:56:20+00:00

I would like to convert a GeoPoint to a screen point in order to

  • 0

I would like to convert a GeoPoint to a screen point in order to identify all objects which are above a touch event.
So, I’ve tried this :

Projection projection = this.mapView.getProjection(); 
GeoPoint gie = new GeoPoint(lat, lon);
Point po = new Point();
projection.toPixels(gie, po);

But, po.x and po.y are not the screen coords, but the mapview coords in pixel instead of lat,lon.

From the android developer website :

toPixels(GeoPoint in, android.graphics.Point out)
Converts the given GeoPoint to onscreen pixel coordinates, relative to the top-left of the MapView that provided this Projection.

So, is it possible to convert it in the correct screen coords ?

I want to know all the x GeoPoint which are next to the + touch event like on the example above :

----------------------------------------------------------------
(0,0) -----------> x                                           |
  |                                                            |
  |                                                            | 
  |                                                            |  <-- My screen
  |                              + (touch event)               |
 \/                            x (my GeoPoint)                 |
  y                                                            |
                                                               | 
---------------------------------------------------------------- 

I get the touch event like that :

@Override
public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();

Here, in this code, x and y are the real screen coords (the hardware ones, not the mapview ones)

I know that I can also convert x,y screen coordinates in GeoPoint to compare them to my GeoPoint, but, because of the zoom level, I can’t get what I want.

  • 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-06-04T07:56:20+00:00Added an answer on June 4, 2026 at 7:56 am

    I’ve found a solution, I don’t know if it’s the best way to get it, but it works!

    I’ve found thank to your help @nickt, the method getScreenRect() which return the current bounds of the screen in screen coordinates.

    Here the code :

    float pisteX;
    float pisteY;
    Projection projection = this.mapView.getProjection(); 
    Point pt = new Point();
    GeoPoint gie = new GeoPoint(latitude,longitude);
    Rect rec = mapView.getScreenRect(new Rect());
    projection.toPixels(gie, pt);
    pisteX = pt.x-rec.left; // car X screen coord
    pisteY = pt.y-rec.top; // car Y screen coord
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to convert a vector into a transitions matrix first (which I
I would like to convert this string {id:1,name:Test1},{id:2,name:Test2} to array of 2 JSON objects.
I would like to convert an IHTMLDOMNode to IHTMLElement in C#, I have tried
I would like to convert object (which holds a string) to double and if
I would like to convert downloaded string to NSArray. First of all I download
I would like to convert a TBitMap to a PBitMap in KOL. I tried
i would like to convert the touch location as a world coordinate in my
I would like to convert from an image (like jpg or png) to PDF.
I would like to convert a yyyy-mm-dd to something like this: Saturday, 2 October
I would like to convert BufferedImage to an image that will display on JSP

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.