2014-10-22 4 views
0

Guyz 위도와 경도로 사용자의 현재 위치를 가져와야하므로 GeoPoint getLocationFromAddress (String strAddress)를 정의 했으므로 steAddress를 매개 변수로 사용하여 addres 문자열을 만든 다음 p1을 geopoint 변수로 반환합니다. 이제 내 질문은 내가 위도와 경도를 별도로 추출하여 google 장소 api.i의 요청 URL에서 사용할 수 있도록하는 것입니다. logcat에있는 해당 p1 변수의 값을 인쇄합니다. 192508911, 731430546 아래의 은 내 호출 함수입니다.GeoPoint 변수에서 위도와 경도 추출

여기 아래

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; 
    } 

답변

0

GeoPoint의 클래스는 구체적인 방법이 있습니다 '.'

double lat = lnglat.getLatitude(); 

double lon = lnglat.getLongitude(); 

https://developer.mapquest.com/content/mobile/android/documentation/api/com/mapquest/android/maps/GeoPoint.html#getLatitude()

+0

하지만 지금 문제는 그것이 배치 점이 있다는 것이다을 1.92508911, 7.31430546과 같은 첫 번째 숫자 이후 올바른 형식은 19.2508911, 73.1430546입니다. 적절한 형식으로 어떻게 가져올 수 있습니까? – user3930098

+0

또한 double lat = lnglat.getLatitude()를 허용하지 않습니다. double lon = lnglat.getLongitude(); double lat = lnglat.getLatitudeE6();으로 작성해야합니다. double lat = lnglat.getLatitude();로 코드를 작성할 때; getLatitude() 메소드는 GeoPoint 유형에 대해 정의되지 않았습니다. 그래서 double lat = lnglat.getLatitudeE6();으로 변경해야했습니다. double lng = lnglat.getLongitudeE6(); – user3930098