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:
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)){
item.setMarker(orangeMarker);
view1ComplainPoleList.add(item.getSnippet());
Log.i("adding",item.getSnippet());
map.invalidate();
}
else{
item.setMarker(greenMarker);
view1ComplainPoleList.remove(item.getSnippet());
Log.i("removing",item.getSnippet());
map.invalidate();
}
}
return true;
}
But this does not seem to be working. whenever i click on an overlayitem it disappears from view. what is going wrong?
UPDATE:
could you also tell me how to load new views when the map is scrolled…?
thank you in advance.
This is very simple to do: