0
votes

I need two overlay item in the map.I have used the following code to get the overlay

enter code here class MapOverlay extends com.google.android.maps.Overlay
 {
     @Override
     public boolean draw(Canvas canvas, MapView mapView,
     boolean shadow, long when)
     {
     super.draw(canvas, mapView, shadow);
     Paint paint = new Paint();
     //---translate the GeoPoint to screen pixels---
     Point screenPts = new Point();
     mapView.getProjection().toPixels(p, screenPts);
    // mapView.getProjection().toPixels(p1, screenPts);
     paint.setStrokeWidth(1);
     paint.setARGB(255, 255, 00, 00);
     paint.setStyle(Paint.Style.STROKE);
     //---add the marker---
     Bitmap bmp = BitmapFactory.decodeResource(
     getResources(), R.drawable.marker);
     canvas.drawBitmap(bmp, screenPts.x, screenPts.y, paint);
     canvas.drawText("Here I am...", screenPts.x, screenPts.y, paint);

 return true;
 }





MapOverlay mapOverlay = new MapOverlay();
List<Overlay> listOfOverlays = mapView.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverlay);
mapView.invalidate();

the below code in in on create portion.from this code i could only get one overlay .how can I use it to get another overlay?I want two overlay,how could I get another one from this code?

2

2 Answers

1
votes

You can use two/multiple overlay by adding MapOverlay on List<Overlay> as listOfOverlays.add(mapOverlay);. To know more information about adding Map overlay in android map, look at the answer Here

0
votes

You just need to repeat the line:

listOfOverlays.add(mapOverlay); 

everytime you want to add another overlay to mapview.