Google maps, plotting markers based on a lat / lng value
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, Ma开发者_高级运维pView 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?
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.
精彩评论