代码:
private MapView mMapView;
private MapController mMapController;
private GeoPoint mGeoPoint;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mMapView = (MapView) findViewById(R.id.mapview);
//设置为交通模式
//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) (29.9885773700000975 * 1000000), (int) (122.2168246800000020 * 1000000));
//定位到成都
mMapController.animateTo(mGeoPoint);
//设置倍数(1-21)
mMapController.setZoom(18);
//添加Overlay,用于显示标注信息
MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
List<Overlay> list = mMapView.getOverlays();
list.add(myLocationOverlay);
}
protected boolean isRouteDisplayed()
{
return false;
}
class MyLocationOverlay extends Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);
return true;
}
}
private MapView mMapView;
private MapController mMapController;
private GeoPoint mGeoPoint;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mMapView = (MapView) findViewById(R.id.mapview);
//设置为交通模式
//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) (29.9885773700000975 * 1000000), (int) (122.2168246800000020 * 1000000));
//定位到成都
mMapController.animateTo(mGeoPoint);
//设置倍数(1-21)
mMapController.setZoom(18);
//添加Overlay,用于显示标注信息
MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
List<Overlay> list = mMapView.getOverlays();
list.add(myLocationOverlay);
}
protected boolean isRouteDisplayed()
{
return false;
}
class MyLocationOverlay extends Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);
return true;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货