Hi, I have the follow code on my application:

In the class Prueba:

import android.os.Bundle;
import android.view.*;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

public class prueba extends MapActivity {

    Drawable defaultMarker = getResources().getDrawable(
            R.drawable.mark);

        Canvas ruta = new Canvas();
        MapView map;
           GeoPoint Point = new GeoPoint((int) (-1.416402 * 1000000), (int)
               (-78.025078 * 1000000));
            @Override
            public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                map = (MapView) findViewById(R.id.map);
                map.getController().setCenter(Point);
                map.displayZoomControls(true);
                map.getController().setZoom(7);
            }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
                menu.add(0,1,2, "My Location");
                //menu 1
                SubMenu sub1 = menu.addSubMenu(3, 2, 3,"Vistas");
                sub1.add(3,3,1, "Satelite");
                sub1.add(3,4,2, "Trafico");
                //menu 2
                SubMenu sub = menu.addSubMenu(2, 5, 1,"Zoom");
                sub.add(2,6,1, "In");
                sub.add(2,7,2, "Out");
                return true;
        }
        @Override
        public boolean onMenuItemSelected(int featureId, MenuItem item) {
        super.onMenuItemSelected(featureId, item);
        WhereAmIOverlay WhereAmIOverlay;
                View zoomView;
                switch (item.getItemId()) {
        case 1:
                defaultMarker.setBounds(0, 0,
defaultMarker.getIntrinsicWidth(),
            defaultMarker.getIntrinsicHeight());
                WhereAmIOverlay = new WhereAmIOverlay(this,defaultMarker);
                map.getController().animateTo(Point);
                map.getOverlays().add(WhereAmIOverlay);
                zoomView = map.getZoomControls();
                zoomView.setLayoutParams(new ViewGroup.LayoutParams
                (ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        //          map.addView(zoomView);
                //    map.displayZoomControls(true);
              //  map.getController().setZoom(16);
              //  map.setClickable(true);
                //map.setEnabled(true);
        return true;
        case 3:
                map.setSatellite(true);
        return true;
        case 4:
                map.setSatellite(false);
        return true;
        case 6:
                int level = map.getZoomLevel();
            map.getController().setZoom(level + 1);
        return true;
        case 7:
                int level1 = map.getZoomLevel();
            map.getController().setZoom(level1 - 1);
        return true;
     }
     return super.onOptionsItemSelected(item);
   }
        @Override
        protected boolean isRouteDisplayed() {
                // TODO Auto-generated method stub
                return false;
        }
}

In the class where should draw I got:


import java.util.ArrayList;
import java.util.List;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import com.google.android.maps.*;

public class WhereAmIOverlay extends ItemizedOverlay< OverlayItem>{
    private List<OverlayItem> mItemList = new
ArrayList<OverlayItem>();
    prueba prueba;
    GeoPoint geoPoint;
    Drawable marker;
    private Projection p;
    Point point;
    Paint paint;
    public WhereAmIOverlay(prueba prueba,Drawable defaultMarker) {
        super(defaultMarker);
        this.prueba = prueba;
        paint = new Paint();
        mItemList.add(new OverlayItem(prueba.Point , "Title",
"Snippet"));
        populate();
    }
    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow)
{
        super.draw(canvas, mapView, true);
         p = mapView.getProjection();
         point =  p.toPixels(prueba.Point,null);
         canvas.drawCircle(point.x, point.y, 10, paint);
    }
    @Override
    protected OverlayItem createItem(int i) {
        return mItemList.get(i);
    }
    @Override
    public int size() {
        return mItemList.size();
    }
}

But It did'n work. Some help please. Thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to