سؤال

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,

هل كانت مفيدة؟

المحلول

Use the new MAPS API V2

Blog article

Video

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top