Chrishan
Chrishan

Reputation: 4106

Load a fake map on Google map in android

In my application I need to overlay an map like image on a Mapview. Which will hide the real map from the user. When User zoom the map, overlay image should also get zoomed. I tried with Mapoverlay method which use to add pins in map but it didn't match with my requirement.

Any idea would be a great help.

Thanks in advance !

Upvotes: 2

Views: 389

Answers (1)

Serdar Dogruyol
Serdar Dogruyol

Reputation: 5157

You need to create your own class which extends ItemizedOverlay and in that classes constructor you can set the default marker as the image that you want the put onto the map.

Something like this.

public class MyOverlay extends ItemizedOverlay {

Context mContext;



@Override
   public void draw(Canvas canvas, MapView mapView, boolean shadow) {
// TODO Auto-generated method stub
super.draw(canvas, mapView, shadow);


    }
@Override
protected OverlayItem createItem(int i) {
    // TODO Auto-generated method stub

    return mOverlays.get(i).overlayItem;
}

public void addOverlay(OverlayItem overlay, int businessId) {

    populate();
}



public MyOverlay(Drawable defaultMarker, Context context) {
    super(boundCenterBottom(defaultMarker));
    mContext = context;
}


@override
protected boolean onTap(int index) {

    return true;
}
}

In your original map Activity you need to do something like this to use your overlay.

List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.myImage);
MyOverlay itemizedoverlay = new MyOverlay(drawable, context);
mapOverlays.add(itemizedoverlay);

Upvotes: 1

Related Questions