从android中的latlng对象获取纬度和经度 [英] Getting latitude and longitude from latlng object in android
问题描述
我试图在Googlemap v2上获取纬度和经度..我已经使用代码设置了mapclay对象的onclick监听器
map.setOnMapClickListener(new OnMapClickListener(){
$ b @Override
public void onMapClick(LatLng latln){
// TODO自动生成的方法存根
String s = latln.toString();
Log.w(dsfdsf,+ s);
}
});
它提供纬度和经度坐标,格式为lat / lng:(xx.xxxxxx,yy .yyyyy)
我需要确切的方法来获取纬度和经度数据..我不想使用split解析数据并获取坐标..
您可以在 Google Maps API参考:
public final class LatLng strong>
公共最终双纬度
纬度,以度为单位。该值在[-90,90]的范围内。
公共最终双经度
经度,以度为单位。这个值在[-180,180]范围内。
所以在你的例子中你应该调用:
double lat = latlng.latitude;
double lng = latlng.longitude;
I am trying to get latitude and longitude on the Googlemap v2.. I have set the onclick listener for mapragment object using the code
map.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng latln) {
// TODO Auto-generated method stub
String s=latln.toString();
Log.w("dsfdsf",""+s);
}
});
It provides be the latitude and longitude coordinates in the format lat/lng: (xx.xxxxxx,yy.yyyyy) I need the exact method to get latitude and longitude data.. I dont want to parse the data using split and get the coordinates..
This can easily be found in the Google Maps API reference:
public final class LatLng
public final double latitude
Latitude, in degrees. This value is in the range [-90, 90].
public final double longitude
Longitude, in degrees. This value is in the range [-180, 180).
So in your example you should call:
double lat = latlng.latitude;
double lng = latlng.longitude;
这篇关于从android中的latlng对象获取纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!