1. 如何初始化百度地图
2. 开启百度地图的定位导航,共有两个方法
1)利用百度地图提供的MyLocationOverlay
2)利用百度地图提供的LocationListener进行监听我的位置的变化
3)百度画路线----待定
BMapManager mapManager = new BMapManager(getApplication()); //mStrKey为百度应用key mapManager.init(mStrKey, null); // 如果使用地图SDK,需要初始化地图Activity super.initMapActivity(mapManager); //开启百度地图API mapManager.start(); //mapView为百度地图控件MapView mapView.setBuiltInZoomControls(false); mapView.setClickable(true); mapView.setEnabled(true); // 得到MapController实例,该实例可以对百度地图进行相关功能的设置,如设置百度地图的放大级别、定位等 mapController = mapView.getController(); //设置显示百度地图的缩放级别 mapController.setZoom(15);// 最大18级,(15)
1)利用百度地图提供的MyLocationOverlay
// 添加定位图层 MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView); // 注册GPS位置更新的事件,让地图能实时显示当前位置 myLocationOverlay.enableMyLocation(); // 开启磁场感应传感器 myLocationOverlay.enableCompass(); mapView.getOverlays().add(myLocationOverlay);
MKLocationManager locationManager = mapManager.getLocationManager(); locationManager.requestLocationUpdates(new LocationListener() { @Override public void onLocationChanged(Location location) { // TODO Auto-generated method stub if (location != null) { updateMyLoading(location.getLatitude(), location.getLongitude()); } } }); private void updateMyLoading(double latitude, double longitude){ Listo = mapView.getOverlays(); final GeoPoint pt = new GeoPoint((int) (location.getLatitude() * 1e6), (int) (location.getLongitude() * 1e6)); if (pt != null) { o.remove(myOverItemT); myOverItemT = getOverItemT(myLocation, pt); o.add(myOverItemT); mapView.invalidate(); } } public OverItemT getOverItemT(Drawable scenicIcon, GeoPoint geo){ //OverItemT该类我自个定义的,继承ItemizedOverlay ,以来显示我的位置的点 OverItemT overLay = new OverItemT(scenicIcon, MapSearchActivity.this, geo, view, mapView); return overLay; }
作者:Super_Level 发表于2013-1-7 11:37:24 原文链接
阅读:42 评论:0 查看评论