2011-10-27 44 views
0

即時通訊新的android和在地圖視圖中工作我想通過點擊一個位置來獲取位置的s logi/lati,谷歌帶我到這個方法 ** protected boolean onTapp GeoPoint的p,MapView的地圖){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;** 

我有變化不大,但其沒有工作可以在任何人會幫我或共享它的一些工作例如在ItemizedOverlay添加此。

回答

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!");