[solved]how to add a new overlay to mapview

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

[solved]how to add a new overlay to mapview

Postby zhanglibo0626 » Sun Dec 28, 2008 3:48 pm

hello everybody.
I am a freshman, my question is how to add a new overlay to mapview? I used several ways, but all failed.

way one:
Overlay OL = new Overlayer(); //error, Cannot instantiate the type Overlay
OL.toTop(p, myMapView);
myMapView.getOverlays().add(OL);

way two:
Drawable myIcon = getResources().getDrawable(R.drawable.icon);
ScaleDrawable myicon = new ScaleDrawable(myIcon, 0, 500, 500);
myMapView.getOverlays().add(new ItemizedOverlay((Drawable)myicon)); //error, Cannot instantiate the type ItemizedOverlay


thx for your help.
waiting.....................
Last edited by zhanglibo0626 on Tue Dec 30, 2008 3:50 pm, edited 1 time in total.
zhanglibo0626
Freshman
Freshman
 
Posts: 3
Joined: Sat Dec 27, 2008 12:00 pm

Top

Postby ndroid » Tue Dec 30, 2008 6:41 am

Have a class that extends Overlay like
protected class MyLocationOverlay extends Overlay {
public MyLocationOverlay(Context context, MapView mapView)
{

}
draw()
{
// override the draw function..
}
}
and the you get the list of overlays from the map and add your overlay to that list..
ndroid
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Dec 15, 2008 1:29 pm

Postby zhanglibo0626 » Tue Dec 30, 2008 9:34 am

thx, I get

ndroid wrote:Have a class that extends Overlay like
protected class MyLocationOverlay extends Overlay {
public MyLocationOverlay(Context context, MapView mapView)
{

}
draw()
{
// override the draw function..
}
}
and the you get the list of overlays from the map and add your overlay to that list..
zhanglibo0626
Freshman
Freshman
 
Posts: 3
Joined: Sat Dec 27, 2008 12:00 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests