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?
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.