Hi,
I am working on android application and I am able to displayed multiple icons on map using ItemizedOverlay and I have also implemented onTap(int index) method of ItemizedOverlay to display icon specific information in a required window.
Now, I want to change icon of selected overlay when user click on some other coponent. I am calling setFocus(OverlayItem) method of ItemizedOverlay to display different icon of specific overlay. it works fine when user tap on any specific overlay but does not change icon when I call setFocus(OverlayItem) method.
Any pointers? what is best way of programtically changing icon of selected overlay in mapView?
I have overriden getMarker method of my custom OverlayItem class to display different markers for different state of overlayItem. and I want to use setFocus(OverlayItem) method to change the state of OverlayItem and also change the marker when selected.
@Override
public Drawable getMarker(int stateBitset){
if(stateBitset==0){
icon = Util.getCategoryMapIcon(0);
icon.setBounds(0-icon.getIntrinsicWidth()/2, 0-icon.getIntrinsicHeight(), icon.getIntrinsicWidth()/2, 0);
return icon;
}else {
icon = Util.getCategoryMapIcon(OverlayItem.ITEM_STATE_SELECTED_MASK);
icon.setBounds(0-icon.getIntrinsicWidth()/2, 0-icon.getIntrinsicHeight(), icon.getIntrinsicWidth()/2, 0);
return icon;
}
}
here Util.getCategoryMapIcon(0) is Utility method to return appropriate icon, this method takes some parameters, which I have removed to make this example look simple.
and below is code to change the state
Button leftNavigation = (Button) findViewById(R.id.left_navigation_button);
leftNavigation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
OverlayItem item = searchResultsOverlay.get(index+1);
setFocus(item);
}
});
Any help will be much appreciated. Thanks, Aamir