How to plot current location in a Google Maps Image

1.6k views Asked by At

I want to create Android App with a still image map, [ custom map ]

in it.

1) current location google map image (screen short). [ it may be our won drawing..] as shown below.

Image point 9.94015,76.273953 9.94015,76.273953 is the location of the image.

In this image the blue plot indicates the current location.

How to do this?

Mercator can do this very easily, but I am very new in programming...

I can't do it.

If any body help me with a sample project I will appreciate it.

2

There are 2 answers

1
vinod On

R u trying to do something like google map marker? If so then u need to use ItemizedOverlay. u will find examples on ItemizedOverlay on net. Just google it for "Examples on ItemizedOverlay".

Do u want to just draw a circle kind of shape on mapView?? If so then this is what u have to do.. Write a class that extends ItemizedOverlay...... In the onDraw method use this code

@Override

public void draw(Canvas canvas, MapView mapView, boolean shadow/*, long when*/) {

    super.draw(canvas, mapView, shadow);

    Paint paint = new Paint();
    // Converts lat/lng-Point to OUR coordinates on the screen.
    android.graphics.Point myScreenCoords = new android.graphics.Point();

    GeoPoint point = new GeoPoint(15340000,75120000);
    mapView.getProjection().toPixels(point, myScreenCoords);
    paint.setStrokeWidth(1);
    paint.setARGB(255, 255, 255, 255);
    paint.setStyle(Paint.Style.STROKE);

    paint.setTextSize(20);
    paint.setColor(Color.RED);
    paint.setStrokeWidth(2);


     canvas.drawText("Here I am...", myScreenCoords.x-10,myScreenCoords.y-48, paint);
    return true;                                                   }
0
IAmGroot On

If you know the map coordinates (left, right, top bottom), you can easily work out how much each pixel represents. Using this and the GPS lat long, just draw a circle at the correct pixel.

So for the X location: (this is not code)

Map left = 10 
Map Right = 15
Image Width = 1000 pixels

Therefore:

each pixel = (15-10)/ 1000
           = 0.005

You are at GPS X coordinate 11.5 So:

11.5 - 10 = 1.5
1.5 / 0.005 = 300

So you need to draw your circle at pixel 300 on the X axis, over your image.

Repeat for Y coordinate. (using height, top and bottom)