2011-10-27 3 views
0

메신저 및지도보기에서 작동하는 새 위치를 얻으 려합니다. 위치를 탭하여지도에서 위치를 가져오고 싶습니다. Google이이 방법으로 이동합니다. ** protected boolean onTapp GeoPoint의 피,지도보기지도) {내가 거의 변화가 있지만 어느 한 날 도와 또는 일부 작업 예제를 공유하시기 바랍니다 것입니다 수 있습니다 작동하지 않습니다와 ItemizedOverlay에 추가해야지도보기의 ontapp() 메소드

if(Map == null) { 
    Map = map; 
    } 
    Geocoder coder = new Geocoder(this.mContext,Locale.getDefault()); 
    try { 


    List<Address> aList = coder.getFromLocation(p.getLatitudeE6()/1e6, p.getLongitudeE6()/1e6, 5); 
    if(aList.size() > 0) { 
    int i = 0; 
    String address = ""; 

    while(aList.get(0).getAddressLine(i) != null) { 
     address+=aList.get(0).getAddressLine(i) + " "; 
     i++; 
    } 


    } 
    } 
    catch (IOException e) { 
    e.printStackTrace(); 
    } 

    return true;** 

.

답변

0

이렇게하면 ... aList = geocoder.getFromLocation (pt.getLatitudeE6()/1E6, pt.getLongitudeE6()/1E6, 1);

   if(aList != null) { 
       Address returnedAddress = aList.get(0); 
       StringBuilder strReturnedAddress = new StringBuilder("\n"); 
       for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) { 
       strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n"); 
       } 
       getlocfrommap.setText(strReturnedAddress.toString()); 
       } 
       else{ 
       getlocfrommap.setText("No Address returned!"); 
       } 
      } catch (IOException e) { 
       // TODO Auto-generated catch block 
       e.printStackTrace(); 
       getlocfrommap.setText("Canont get Address!"); 
관련 문제