How are you going to create ItemizedOverlay, which covers the entire map?
I have several map markers that are ItemizedOverlay classes.
I want to create another ItemizedOverlay that spans the entire map in order to intercept touch events that are not on my markers except the map itself. I read in other SO questions, such as one , that the only way to do this is through ItemizedOverlay-> onTap. The problem is that I don’t know how to create a Drawable marker that spans the entire map.
I experimented with LinearLayout line outputs, but apparently it can use a drawn image as a marker.
Here is my code
private class BackgroundOverlay<Item extends OverlayItem> extends ItemizedOverlay<OverlayItem>{
private ArrayList<OverlayItem> overlays = new ArrayList<OverlayItem>();
public BackgroundOverlay(Drawable defaultMarker,Context context) {
super(boundCenterBottom(defaultMarker));
}
@Override
protected OverlayItem createItem(int i) {
return overlays.get(i);
}
@Override
public int size() {
return overlays.size();
}
public void addOverlay(OverlayItem overlay) {
overlays.add(overlay);
populate();
}
protected boolean onTap(int index){
Toast.makeText(getApplicationContext(), "Touched background",Toast.LENGTH_SHORT).show();
return true;
}
}
and create an overlay
Drawable d=this.getResources().getDrawable(R.layout.full_screen);
BackgroundOverlay<OverlayItem> lay = new BackgroundOverlay<OverlayItem>(d,this);
overlayItem = new OverlayItem(this.mapView.getMapCenter(), "", "");
lay.addOverlay(overlayItem);
mapOverlays.add(lay);
and sharpened xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/blue">
</LinearLayout>
Thanks in advance