2013-01-23 30 views
0

按類重疊並從該類調用onTap方法我可以在我的地圖上顯示drawable。我想要做的事情只是當用戶點擊地圖時(第一個水龍頭)顯示一個可繪製的圖標,而不是通過點擊一次又一次顯示在不同的地方繪製。這可能嗎?在地圖上僅顯示一次可點按

+0

任何代碼?配置?截圖?即使對問題的恰當解釋? – Alpay

+0

我編輯了這個問題。我希望現在更好.. – Blubar

回答

0
override you onTap() method of Overlay 

    @Override 
    protected boolean onTap(int index) { 
     Drawable srcdrawable = getApplicationContext().getResources().getDrawable(R.drawable.pin_blue); 
    CustomItemizedOverlay srcitemizedOverlay = new CustomItemizedOverlay(srcdrawable, getApplicationContext()); 
    forloop(setoflocations){ 
    GeoPoint srcpoint = new GeoPoint((int)(Double.parseDouble(lat) * 1E6),(int)(//latitude and longitude of user tapped location... 
Double.parseDouble(lng)* 1E6)); 
    OverlayItem srcoverlayitem = new OverlayItem(srcpoint, "Hello!", "This is your Location."); 
    if(srcitemizedOverlay!=null && mapController!=null){ 
    srcitemizedOverlay.addOverlay(overlayitem); 
    mapController.animateTo(point); 
    animatePoint = point; 
    } 
    } 
    mapView.getOverlays().clear(); 
    mapView.getOverlays().add(srcitemizedOverlay); 

    // pop up a alert dialog here and ask user for confirmation 

    } 
+0

你的意思是「覆蓋你的MapView的onTap()方法」。你的意思是來自課堂Overlay?公共布爾onTap(GeoPoint的地點,MapView地圖視圖)? – Blubar

+0

是的,你需要覆蓋Overlay類的onTap()方法,就像我上面提到的.. – Ajit

+0

我不知道你在做什麼。爲什麼在那裏有一個for循環。並onTap方法獲取2個argomants不是一個..你能解釋我更多plz – Blubar

相關問題