How to change the marker for the overlay on tap for android?

前端 未结 4 1461
北海茫月
北海茫月 2021-02-07 20:06

i have made an application in which i need to change the drawable of an overlayitem when a user clicks on it. i am using the following code to achieve this effect:



        
4条回答
  •  时光取名叫无心
    2021-02-07 21:08

    Use Setbounds api to set the bounds as follows: Edited your original code

    protected boolean onTap(int index) {
        OverlayItem item = mOverlays.get(index);
        if(item.getTitle().equals("true")){
            if(item.getMarker(OverlayItem.ITEM_STATE_FOCUSED_MASK).equals(greenMarker)){
                orangeMarker.setBounds(0,0,orangeMarker.getIntrinsicWidth(),orangeMarker.getIntrinsicHeight());
                item.setMarker(orangeMarker);
                view1ComplainPoleList.add(item.getSnippet());
                Log.i("adding",item.getSnippet());
                map.invalidate();
            }
            else{
                greenMarker.setBounds(0,0,greenMarker.getIntrinsicWidth(),greenMarker.getIntrinsicHeight());
                item.setMarker(greenMarker);
                view1ComplainPoleList.remove(item.getSnippet());
                Log.i("removing",item.getSnippet());
                map.invalidate();
            }
        }
        return true;
    }
    

提交回复
热议问题