0

i am trying to scale pictures in a Android map itemizedOverlay, i got it working to the point where i can see 10 pictures, i got zoomControle but nothing else really,

this is the MapItems class that extends ItemizedOverlay, optimizations is welcome

import java.util.ArrayList;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class MapItems extends ItemizedOverlay 
{

    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
    Context mContext;

    public MapItems(Drawable defaultMarker) 
    {
        super(boundCenterBottom(defaultMarker));
    }

    @Override
    public void draw(android.graphics.Canvas canvas,MapView mapView,boolean shadow) 
    {
        /*
        Log.d("MapAc", String.valueOf(mapView.getZoomLevel()));
        if(mapView.getZoomLevel() > 20)
        {
            Log.d("MapAc", "scaling up");
            canvas.scale(1.2f, 1.2f);
        }

        */

        super.draw(canvas,mapView,false);
    }


    public MapItems(Context context) 
    {
        super(boundCenterBottom(context.getResources().getDrawable(R.drawable.app_icon_clean))); 
        mContext = context;
    }

    public void addOverlay(OverlayItem overlay) 
    {
        mOverlays.add(overlay);
        populate();
    }

    public void clearOverlay()
    {
        mOverlays.clear();
    }

    @Override
    protected OverlayItem createItem(int i) 
    {
        return mOverlays.get(i);
    }

    @Override
    public int size() 
    {
        return mOverlays.size();
    }

     @Override
     protected boolean onTap(int index) 
     {
         /* ToDo
       OverlayItem item = mOverlays.get(index);
       AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
       dialog.setTitle(item.getTitle());
       dialog.setMessage(item.getSnippet());
       dialog.show();
        */
       return true;
    }

}

i have been trying to scale in the draw method, using canvas.Scale, however this seems to redraw the canvas in another location, together with the old canvas"in its original size", i am not sure if i am approaching this problem from the right angle, or if it is simply a matter of clearing the screen, i have been using a few days to figure this out, so a method to scale my pictures correct when zooming is VERY appreciated,

Wojciech Wirzbicki
  • 3,887
  • 6
  • 36
  • 59
Christopher Bonitz
  • 828
  • 1
  • 10
  • 22

1 Answers1

0

Use the new MAPS API V2

Blog article

Video

David
  • 3,971
  • 1
  • 26
  • 65
  • This is properly a valid solution, however for future readers, this is not so easy as you would properly think, i am now struggling to make it work in eclipse, there is not a lot of tutorials out there yet – Christopher Bonitz Dec 29 '12 at 17:35
  • Learning deprecated stuff is not the way to go either. – David Dec 29 '12 at 20:12
  • Bonus tip... if you got a older version of eclipse installed, this can course you trouble, please install the android sdk with eclipse, i got all kind of strange results using my old setup – Christopher Bonitz Jan 09 '13 at 12:09