电子地图
地图
电子地图
修改定位图标
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 { @Override public 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();//162 mCityName = 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-19 map.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);