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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:10:22+00:00 2026-06-13T15:10:22+00:00

I use the follow code to get coordinates and altitude simple clicking in a

  • 0

I use the follow code to get coordinates and altitude simple clicking in a place on the map… for example if I click on a New York Street the apps returns to me the New York coordinates

public void onLocationChanged(Location location) {
    double lat = (double) (location.getLatitude());
    double lng = (double) (location.getLongitude());
    double alt = (double) (location.getAltitude());
}

I use this method to retrieve the data about position on touch in a place

@Override
public boolean onTap(GeoPoint p, MapView map) {     

    List<Overlay> overlays = map.getOverlays();

    Message message = new Message();

    Bundle data = new Bundle();

    data.putInt("latitude", p.getLatitudeE6());

    data.putInt("longitude", p.getLongitudeE6());

    message.setData(data);

    handler.sendMessage(message);       

    return super.onTap(p, map);
}   

Unfortunately seems that GeoPoint object has no method like p.getAltitudeE6() analogue to longitude and latitude.

So, getting latitude and longitude tapping the map works fine, but altitude returns 0 in every clicked place.

Is there a way to solve this problem?

  • 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-13T15:10:23+00:00Added an answer on June 13, 2026 at 3:10 pm

    The mapping data dose not include altitude information. You can use the Google Elevation API to take the latitude and longitude you have and get elevation. It’s an online lookup so not necessarily very responsive.

    Added code example.

    public double getAltitudeFromNet(double def, Location loc) {
    Log.v(TAG, "Looking up net altitude");
    double result = -100000.0;
    HttpParams httpParameters = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParameters, 5000);
    HttpConnectionParams.setSoTimeout(httpParameters, 5000);
    
    HttpClient httpClient = new DefaultHttpClient(httpParameters);
    HttpContext localContext = new BasicHttpContext();
    String url = "http://maps.googleapis.com/maps/api/elevation/" + "xml?locations="
        + String.valueOf(loc.getLatitude()) + "," + String.valueOf(loc.getLongitude()) + "&sensor=true";
    HttpGet httpGet = new HttpGet(url);
    try {
      HttpResponse response = httpClient.execute(httpGet, localContext);
      HttpEntity entity = response.getEntity();
      if (entity != null) {
        InputStream instream = entity.getContent();
        int r = -1;
        StringBuffer respStr = new StringBuffer();
        while ((r = instream.read()) != -1)
          respStr.append((char) r);
        String tagOpen = "<elevation>";
        String tagClose = "</elevation>";
        if (respStr.indexOf(tagOpen) != -1) {
          int start = respStr.indexOf(tagOpen) + tagOpen.length();
          int end = respStr.indexOf(tagClose);
          String value = respStr.substring(start, end);
          result = (double) (Double.parseDouble(value));
    
        }
        instream.close();
      }
    } catch (ClientProtocolException e) {
      Log.w(TAG, "Looking up net altitude ClientProtocolException", e);
    } catch (IOException e) {
      Log.w(TAG, "Looking up net altitude IOException", e);
    }
    
    Log.i(TAG, "got net altitude " + (int) result);
    if (result > -1000) {
      return result;
    } else {
      return def;
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could I get very easy to follow code examples on the following: Use browser
Code snippet to follow. I have a struct (example code has class, tried both,
I get a code for Fibonacci Heap. This code uses the follow function to
I'm sure that I'm missing something simple here. I'm trying to follow a Code
I need to build some client side code which follows this use case: An
All the code examples always use base() as follows class A { public A()
As for me, what I use is as follows recently yasnippets -- http://code.google.com/p/yasnippet/ If
I use do auto indenting follow lines that begin with python keywords in Vim
I am trying to follow a tutorial about how to use ant to build
I didn't follow my own best practices (use only derived controls), and I dragged

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.