views:

67

answers:

3

Hey Guys,

I've got the following code which plots a marker at the specified x/y screen co-ordinates. like so...

            public boolean draw(Canvas canvas, MapView mapView, 
    boolean shadow, long when) 
    {
        super.draw(canvas, mapView, shadow);                   

        //---translate the GeoPoint to screen pixels---
        Point screenPts = new Point();
        mapView.getProjection().toPixels(p, screenPts);

        //---add the marker---
        Bitmap bmp = BitmapFactory.decodeResource(
            getResources(), R.drawable.marker);            
        canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);  
        System.out.println("X: " + screenPts.x + "Y: " + screenPts.y);
        return true;
    }

But is there anything in the API or known methods for plotting points based on a lat/lng?

+1  A: 

http://developer.android.com/resources/tutorials/views/hello-mapview.html

Aaron Saunders
I'm using this tutorial but I'm hitting a null pointer. I've updated my question, care to give me a hand?
Ulkmun
can you provide the stack dump? or addition information on the error
Aaron Saunders
A: 

Check the tutorial here: http://mobiforge.com/developing/story/using-google-maps-android

Chris Thompson
A: 

One solution would be to create an bitmap image with a point (small circle) and use this image as a marker. Then you can keep your code as it is.

You can use any Drawable as a marker. This article on Drawable Resources should help you to find the best fitting implementation for a point marker.

Andreas_D