public class AndroidGooleMapDemo extends MapActivity {
/** Called when the activity is first created. */
private MapView mMapView;
private MapController mMapController;
private GeoPoint mGeoPoint;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mMapView = (MapView) findViewById(R.id.MapView01); // 设置为交通模式
mMapView.setTraffic(true);

// //设置为卫星模式

// mMapView.setSatellite(true);

// //设置为街景模式

// //mMapView.setStreetView(false);

// //取得MapController对象(控制MapView)

mMapController = mMapView.getController();

mMapView.setEnabled(true);

mMapView.setClickable(true);
// //设置地图支持缩放
mMapView.setBuiltInZoomControls(true);
// //设置起点为成都
mGeoPoint=new GeoPoint((int)(30.659259*1000000),(int)(104.065762*1000000));

// //定位到成都
mMapController.animateTo(mGeoPoint);

// //设置倍数(1-21)

mMapController.setZoom(12);


// //添加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.home);
canvas.drawBitmap(bmp,myScreenCoords.x,myScreenCoords.y,paint);
canvas.drawText("天府广场",myScreenCoords.x, myScreenCoords.y,paint);
return true;

}
}

更多相关文章

  1. Android中的设计模式——DataSetObservable 观察者模式
  2. Activity学习(二):Activity的启动模式(转载)
  3. Activity 启动模式
  4. android中的四种启动模式
  5. android百度地图定位,点击给定经纬度的某点进行弹窗
  6. Android 夜间模式系列笔记(一)AppCompatDelegate
  7. Android MVP模式
  8. Android MVP 模式

随机推荐

  1. Android(安卓)P 开发者预览版 · 操作指
  2. Android(安卓)真的能跨平台吗?(翻译)
  3. android Java开发设计模式及在android中
  4. 腾讯优测优分享 | Android性能测试工具化
  5. 将程序安装到SD卡
  6. Android单元测试——初探
  7. Android支持Perl
  8. Android实现分享(Share)功能
  9. Android基础 : Android(安卓)Service
  10. Android(安卓)数字签名学习笔记