Android Overlay Full Map

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>();

    /**
     * @param defaultMarker
     */
    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

+3
2

, . , Overlay duh. onTap.

    private class BackgroundOverlay extends Overlay{
    public boolean onTap (final GeoPoint p, final MapView mapView){
        Toast.makeText(getApplicationContext(), "Touched background",Toast.LENGTH_SHORT).show();
        hideOtherFires(mapView.getOverlays());          
        return true;
    }

,

//add a background overlay to intercept touches on background
    BackgroundOverlay lay = new BackgroundOverlay();
    mapOverlays.add(lay);
+4

Overlay onTap ItemizedOverlays:

/* (non-Javadoc)
 * @see com.google.android.maps.Overlay#onTap(com.google.android.maps.GeoPoint, com.google.android.maps.MapView)
 */
@Override
public boolean onTap(GeoPoint p, MapView mapView) {
    super.onTap(p, mapView);
    OverlayItem item = getFocus();
    mapView.refreshDrawableState();
    return false;
}

, , onTap ( int) .

-:

onTap(int index) - OverlayItems

onTap(GeoPoint p, MapView mapView) -

0

All Articles