android google地图得到 此手机的x y坐标,在线等
下面一段mapactivity代码,可正常显示地图,如下
public class Map4Activity extends MapActivity{
private MapView mMapView;
private MapController mMapController;
private GeoPoint mGeoPoint;
private GeoPoint mGeoPoint2;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.setStreetView(false); //取得MapController对象(控制MapView)
mMapController = mMapView.getController();
mMapView.setEnabled(true);
mMapView.setClickable(true); //设置地图支持缩放
mMapView.setBuiltInZoomControls(true); //设置起点为成都
mGeoPoint = new GeoPoint((int) (28.68 * 1000000), (int) (115.89 * 1000000)); //定位到成都
mMapController.animateTo(mGeoPoint); //设置倍数(1-21)
mMapController.setZoom(15); //添加Overlay,用于显示标注信息
MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
List<Overlay> list = mMapView.getOverlays();
list.add(myLocationOverlay);
}
protected boolean isRouteDisplayed()
{
return false;
}
class MyLocationOverlay extends Overlay {
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);
Paint paint = new Paint();
Point myScreenCoords = new Point();
mapView.getProjection().toPixels(mGeoPoint, myScreenCoords);
paint.setStrokeWidth(1);
paint.setARGB(255, 255, 0, 0);
paint.setStyle(Paint.Style.STROKE);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.map_point);
String xx="-1655";
String yy="646";
Float x1;
x1=Float.parseFloat(xx);
Float y1;
y1=Float.parseFloat(yy);
canvas.drawBitmap(bmp, myScreenCoords.x+50, myScreenCoords.y+50, paint);
canvas.drawText("天府广场", myScreenCoords.x+50, myScreenCoords.y+50, paint);
System.out.println("x"+myScreenCoords.x);
return true;
}
}
}
现需:如何得到此手机的x y坐标呢,thanks