Android 从地理点变量中提取纬度和经度

Android 从地理点变量中提取纬度和经度,android,latitude-longitude,geopoints,Android,Latitude Longitude,Geopoints,Guyz我需要获取用户当前位置的纬度和经度,所以我定义了GeoPoint getLocationFromAddressString StradAddress,它将SteadAddress作为字符串添加的参数,然后返回p1作为GeoPoint变量。现在我的问题是,我应该如何从中分别提取纬度和经度,以便在google places api的请求url中使用。我在logcat its 1925089111731430546。 下面是我的调用函数: GeoPoint lnglat=getLocat

Guyz我需要获取用户当前位置的纬度和经度,所以我定义了GeoPoint getLocationFromAddressString StradAddress,它将SteadAddress作为字符串添加的参数,然后返回p1作为GeoPoint变量。现在我的问题是,我应该如何从中分别提取纬度和经度,以便在google places api的请求url中使用。我在logcat its 1925089111731430546。 下面是我的调用函数:

   GeoPoint lnglat=getLocationFromAddress(keyword);
   System.out.println(lnglat);
   Log.d("Location Point",lnglat.toString() ); 
    public GeoPoint getLocationFromAddress(String strAddress){

    Geocoder coder = new Geocoder(this);
    List<Address> address;
    GeoPoint p1 = null;

    try {
    address = coder.getFromLocationName(strAddress,5);
    if (address == null) {
        return null;
    }
    Address location = address.get(0);
    location.getLatitude();
    location.getLongitude();

    p1 = new GeoPoint((int) (location.getLatitude() * 1E6),
                      (int) (location.getLongitude() * 1E6));

    return p1;
    }
    catch(Exception e){
    e.printStackTrace();
    }
    return p1;
   }
下面是返回函数:

   GeoPoint lnglat=getLocationFromAddress(keyword);
   System.out.println(lnglat);
   Log.d("Location Point",lnglat.toString() ); 
    public GeoPoint getLocationFromAddress(String strAddress){

    Geocoder coder = new Geocoder(this);
    List<Address> address;
    GeoPoint p1 = null;

    try {
    address = coder.getFromLocationName(strAddress,5);
    if (address == null) {
        return null;
    }
    Address location = address.get(0);
    location.getLatitude();
    location.getLongitude();

    p1 = new GeoPoint((int) (location.getLatitude() * 1E6),
                      (int) (location.getLongitude() * 1E6));

    return p1;
    }
    catch(Exception e){
    e.printStackTrace();
    }
    return p1;
   }

“地质点”类具有特定的方法:

double lat = lnglat.getLatitude();

double lon = lnglat.getLongitude();

但现在的问题是,它将点“.”放在第一个数字后面,比如1.92508911,7.31430546,而它的正确格式是19.2508911,73.1430546。如何才能获得正确的格式?而且它不接受双lat=lnglat.getLatitude;双lon=lnglat.getLongitude;我需要把它写成double-lat=lnglat.getlatudee6;当我以double lat=lnglat.getLatitude编写代码时;它表示类型GeoPoint的getLatitude方法未定义。所以我需要更改为double lat=lnglat.getLatitudeE6;双液化天然气=lnglat.getLongitudeE6;