2013-08-06 123 views
0

如何在標記點擊時獲得標記項目位置,就像在ListView的itemclick中一樣?Android地圖v2 - 在標記點擊時獲取標記位置

確定我得到了答案

@Override 
public void onInfoWindowClick(Marker marker) { 
    // TODO Auto-generated method stub 
    System.out.println("onInfoWindowClick method calling and marker position is "+marker.getPosition()); 

    String title =marker.getTitle(); 

    for(int i=0;i<CommonUtilities.CoffeeShop_array_list.size();i++){ 
     String s =CommonUtilities.CoffeeShop_array_list.get(i).Title; 

     if(title.equalsIgnoreCase(s)){ 
      **marker_position** = i; 
      System.out.println("position of marker - "+marker_position); 
     } 
    } 
} 
+0

有跡象表明,我害怕標記的位置!你能解釋一下你想達到的目標嗎? –

回答

4

這可能會幫助你

   mGoogleMap.setOnInfoWindowClickListener(
          new OnInfoWindowClickListener(){ 
          @Override 
          public void onInfoWindowClick(Marker arg0) { 

           // TODO Auto-generated method stub 
           arg0.hideInfoWindow(); 
           double dlat =arg0.getPosition().latitude; 
           double dlon =arg0.getPosition().longitude; 
           String slat = String.valueOf(dlat); 
           String slon = String.valueOf(dlon); 
          alert.showpickAlertDialog2(PlacesMapActivity.this,slat , slon, arg0.getSnippet()); 
          } 
          } 
         ); 
0

這裏是從標記獲取地點短代碼: -

LatLng myLatLng = new LatLng(myMarker.getPosition().latitude,myMarker.getPosition().longitude); 

嘗試。

相關問題