集地图、定位、导航于一体
- 效果视频
- 电子地图
- 地图
- 修改定位图标
- 定位
- 导航
- 尾言
效果视频
电子地图
地图
电子地图
修改定位图标
MyLocationConfiguration.LocationMode mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;BitmapDescriptor mCurrentMarker = BitmapDescriptorFactory.fromResource(R.drawable.icon_location);
map.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker,0x00000000,0x00000000));
定位
新版本API通过继承BDAbstractLocationListener实现获取定位信息
class MyBaiduMap extends BDAbstractLocationListener {@Overridepublic void onReceiveLocation(BDLocation bdLocation) {Latitude = bdLocation.getLatitude();//获取纬度Longitude = bdLocation.getLongitude();//获取经度if (bdLocation.getLocType() == com.baidu.location.BDLocation.TypeGpsLocation || bdLocation.getLocType() == com.baidu.location.BDLocation.TypeNetWorkLocation) {navigateTo(bdLocation);}int error = bdLocation.getLocType();//162mCityName = bdLocation.getCity();if (mCityName!= null && cityFalg == false){UpdateView();cityFalg = true;}//Toast.makeText(MainActivity.this,mCityName,Toast.LENGTH_LONG).show();//网络定位失败,因为百度定位服务无法解密请求查询,请检查so文件!"//Toast.makeText(MainActivity.this,"error"+error,Toast.LENGTH_LONG).show();}}
//if (isFirstLocate){LatLng lng = new LatLng(location.getLatitude(),location.getLongitude());//指定经纬度MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(lng);map.animateMapStatus(update);update = MapStatusUpdateFactory.zoomTo(16f);//百度地图缩放级别限定在3-19map.animateMapStatus(update);isFirstLocate = false;//}MyLocationData.Builder builder = new MyLocationData.Builder();builder.latitude(location.getLatitude());//纬度builder.longitude(location.getLongitude());//经度MyLocationData locationData = builder.build();map.setMyLocationData(locationData);
导航
导航
尾言
本文仅用于记录本人学习历程