com.baidu.mapapi.map.MapStatusUpdate Java Examples
The following examples show how to use
com.baidu.mapapi.map.MapStatusUpdate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From Study_Android_Demo with Apache License 2.0 | 6 votes |
@Override public void onReceiveLocation(BDLocation bdLocation) { //查看定位结果 Log.d("Tag", "定位返回----" + bdLocation.getAddrStr()); //定位成功后,把定位的点,设置地图的中心点 //包装经纬,从定位信息中,获取经纬度 LatLng currentLatLng = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); //构建地图状态 MapStatus status = new MapStatus.Builder() //包装经纬度 .target(currentLatLng) //缩放等级 .zoom(15) //构建 .build(); //通过地图工厂设置地图状态 MapStatusUpdate update = MapStatusUpdateFactory.newMapStatus(status); //更新地图界面 mBaiduMap.setMapStatus(update); }
Example #2
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) { // 通知是适配器第position个item被选择了 mAdapter.setNotifyTip(position); mAdapter.notifyDataSetChanged(); BitmapDescriptor mSelectIco = BitmapDescriptorFactory .fromResource(R.drawable.picker_map_geo_icon); mBaiduMap.clear(); PoiInfo info = (PoiInfo) mAdapter.getItem(position); LatLng la = info.location; // 动画跳转 MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(la); mBaiduMap.animateMapStatus(u); // 添加覆盖物 OverlayOptions ooA = new MarkerOptions().position(la) .icon(mSelectIco).anchor(0.5f, 0.5f); mBaiduMap.addOverlay(ooA); mLoactionLatLng = info.location; mAddress = info.address; mName = info.name; mCity = info.city; mLatitude = info.location.latitude; mLongitude = info.location.longitude; mStreet = info.name;//地图对应位置文字描述 }
Example #3
Source File: MainActivity.java From VirtualLocation with Apache License 2.0 | 6 votes |
/** * iniMap 初始化地图 */ private void iniMap() { LocationClientOption option = new LocationClientOption(); option.setOpenGps(true);// 打开gps option.setCoorType("bd09ll"); // 设置坐标类型 option.setScanSpan(3000); mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; // 缩放 MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(14.0f); mBaiduMap.setMapStatus(msu); mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker)); mLocClient.setLocOption(option); mLocClient.start(); initOverlay(); // 开启线程,一直修改GPS坐标 LocationUtil.startLocaton(); }
Example #4
Source File: MapFragment.java From MapForTour with MIT License | 6 votes |
@Override public boolean onMarkerClick(Marker marker) { Log.d("lml", "MapFragment:覆盖物被点击"); baiduMap.hideInfoWindow(); if (marker != null) { latLngshow = marker.getPosition(); reverseGeoCodeOption.location(latLngshow); geoCoder.reverseGeoCode(reverseGeoCodeOption); tvAddOverlayGeoCoder.setText("正在获取详细位置"); bundle = marker.getExtraInfo(); generalIsMale = bundle.getString("general").equals("m"); layoutAddOverlayRadarNearbyItem.setBackgroundColor(getResources().getColor(generalIsMale ? R.color.blue : R.color.pink)); imageViewAddOverlayItem.setImageResource(generalIsMale ? R.mipmap.map_portrait_man : R.mipmap.map_portrait_woman); tvAddOverlayItemUserID.setText(bundle.getString("userID")); tvAddOverlayItemDistance.setText("距离" + bundle.getInt("distance") + "米 "); tvAddOverlayItemLatlng.setText("坐标: " + latLngshow.latitude + " , " + latLngshow.longitude + " "); Log.d("lml", "MapFragment显示的信息:" + bundle.getString("userID")); Log.d("lml", bundle.getString("general") + ";" + generalIsMale); baiduMap.showInfoWindow(new InfoWindow(viewOverlayItem, marker.getPosition(), -70)); MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(marker.getPosition()); baiduMap.animateMapStatus(update); return true; } else return false; }
Example #5
Source File: MapFragment.java From MapForTour with MIT License | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_map, container, false); // Inflate the layout for this fragment switchLocation = (Switch) view.findViewById(R.id.switchLocation); switchLBSTrace = (Switch) view.findViewById(R.id.switchLBSTrace); switchLocation.setOnCheckedChangeListener(this); switchLBSTrace.setOnCheckedChangeListener(this); mMapView = (TextureMapView) view.findViewById(R.id.bmapView); baiduMap = mMapView.getMap(); baiduMap.setMyLocationConfigeration(new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, false, null)); application.setMaxZoomLevel(baiduMap.getMaxZoomLevel()); // 开启定位图层 baiduMap.setMyLocationEnabled(true); baiduMap.setOnMarkerClickListener(this); //再次进入地图fragment时界面刷新 if (application.latLng != null) { MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(application.getLatLng(), application.getMaxZoomLevel() - 2); baiduMap.animateMapStatus(u);//动画移动摄像头 if (radarNearbyInfoList != null) { refreshMapUI(); } } return view; }
Example #6
Source File: MapFragment.java From apollo-DuerOS with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_map, container, false); initFile(); MapSdkWrapper.setCruiseChangeListener(onLocationListener); NetworkConnectChangedReceiver.setNetworkLtListener(onNetworkChangeListener); DateChangeReceiver.setDateChangeListener(onDateChangeListener); initView(view); if (mMapView != null) { mBaiduMap = mMapView.getMap(); } if (NetworkUtil.isNetworkConnected(getActivity())) { initMap(); } else if (mBaiduMap != null) { MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5); mBaiduMap.animateMapStatus(u); } return view; }
Example #7
Source File: MainActivity.java From Mobike with Apache License 2.0 | 6 votes |
public void onMapStatusChangeFinish(MapStatus mapStatus) { String _str = mapStatus.toString(); String _regex = "target lat: (.*)\ntarget lng"; String _regex2 = "target lng: (.*)\ntarget screen x"; changeLatitude = Double.parseDouble(latlng(_regex, _str)); changeLongitude = Double.parseDouble(latlng(_regex2, _str)); LatLng changeLL = new LatLng(changeLatitude, changeLongitude); startNodeStr = PlanNode.withLocation(changeLL); Log.d(TAG, "changeLatitude-----change--------" + changeLatitude); Log.d(TAG, "changeLongitude-----change--------" + changeLongitude); if (!isNeedCurrentlocation) { MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(changeLL); baiduMap.setMapStatus(u); if (Math.hypot((changeLatitude - currentLatitude), (changeLongitude - currentLongitude)) > 0.00001) { Logger.d(Math.hypot((changeLatitude - currentLatitude), (changeLongitude - currentLongitude))); if (routeOverlay != null) routeOverlay.removeFromMap(); addOverLayout(changeLatitude, changeLongitude); } } }
Example #8
Source File: MainActivity.java From Mobike with Apache License 2.0 | 6 votes |
/** * des:地图跳到指定位置 * * @param location */ private void navigateTo(BDLocation location) { if (isFirstLocation) { LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(ll); baiduMap.animateMapStatus(update); update = MapStatusUpdateFactory.zoomTo(18f); baiduMap.animateMapStatus(update); isFirstLocation = false; } MyLocationData.Builder builder = new MyLocationData.Builder(); builder.latitude(location.getLatitude()); builder.longitude(location.getLongitude()); MyLocationData data = builder.build(); baiduMap.setMyLocationData(data); }
Example #9
Source File: LocationActivity.java From Conquer with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { // map view 销毁后不在处理新接收的位置 if (location == null || mMapView == null) return; if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { BmobLog.i("获取坐标相同");// 若两次请求获取到的地理位置坐标是相同的,则不再定位 mLocClient.stop(); return; } } lastLocation = location; BmobLog.i("lontitude = " + location.getLongitude() + ",latitude = " + location.getLatitude() + ",地址 = " + lastLocation.getAddrStr()); MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius()) // 此处设置开发者获取到的方向信息,顺时针0-360 .direction(100).latitude(location.getLatitude()).longitude(location.getLongitude()).build(); mBaiduMap.setMyLocationData(locData); LatLng ll = new LatLng(location.getLatitude(), location.getLongitude()); String address = location.getAddrStr(); if (address != null && !address.equals("")) { lastLocation.setAddrStr(address); } else { // 反Geo搜索 mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(ll)); } // 显示在地图上 MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); // 设置按钮可点击 // mHeaderLayout.getRightImageButton().setEnabled(true); }
Example #10
Source File: BaiduMapActivity.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { if (location == null) { return; } Log.d("map", "On location change received:" + location); Log.d("map", "addr:" + location.getAddrStr()); sendButton.setEnabled(true); if (progressDialog != null) { progressDialog.dismiss(); } if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { Log.d("map", "same location, skip refresh"); // mMapView.refresh(); //need this refresh? return; } } lastLocation = location; mBaiduMap.clear(); LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
Example #11
Source File: BaiduMapActivity.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 5 votes |
private void showMap(double latitude, double longtitude, String address) { sendButton.setVisibility(View.GONE); LatLng llA = new LatLng(latitude, longtitude); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
Example #12
Source File: EaseBaiduMapActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { if (location == null) { return; } Log.d("map", "On location change received:" + location); Log.d("map", "addr:" + location.getAddrStr()); sendButton.setEnabled(true); if (progressDialog != null) { progressDialog.dismiss(); } if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { Log.d("map", "same location, skip refresh"); // mMapView.refresh(); //need this refresh? return; } } lastLocation = location; mBaiduMap.clear(); LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.ease_icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
Example #13
Source File: EaseBaiduMapActivity.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
private void showMap(double latitude, double longtitude, String address) { sendButton.setVisibility(View.GONE); LatLng llA = new LatLng(latitude, longtitude); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.ease_icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
Example #14
Source File: MapFragment.java From MapForTour with MIT License | 5 votes |
public void setBaiduMapLocationData(MyLocationData locData) { baiduMap.setMyLocationData(locData); if (isFirstLocate) { MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(application.getLatLng(), application.getMaxZoomLevel() - 2); baiduMap.animateMapStatus(u);//动画移动摄像头 isFirstLocate = false; } Log.d("lml", "MapFragment - 设置一次位置"); }
Example #15
Source File: MapActivity.java From foodie-app with Apache License 2.0 | 5 votes |
private void startLocationOverlap() { //开启定位图层 mBaiduMap.setMyLocationEnabled(true); //构造定位数据 MyLocationData locData = new MyLocationData.Builder() .accuracy(mLocation.getRadius()) // 此处设置开发者获取到的方向信息,顺时针0-360 .direction(100).latitude(mLocation.getLatitude()) .longitude(mLocation.getLongitude()).build(); // 设置定位数据 mBaiduMap.setMyLocationData(locData); // 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标) //构建Marker图标 BitmapDescriptor bitmap = BitmapDescriptorFactory .fromResource(R.drawable.my_location); //bitmap. MyLocationConfiguration config = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, bitmap); mBaiduMap.setMyLocationConfigeration(config); //中心点为我的位置 LatLng cenpt = new LatLng(locData.latitude, locData.longitude); //定义地图状态 MapStatus mMapStatus = new MapStatus.Builder() .target(cenpt) .zoom(mCurrentLevel) .build(); //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化 MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus); //改变地图状态 mBaiduMap.setMapStatus(mMapStatusUpdate); // 当不需要定位图层时关闭定位图层 //mBaiduMap.setMyLocationEnabled(false); }
Example #16
Source File: LocationActivity.java From Conquer with Apache License 2.0 | 5 votes |
private void initLocClient() { // 开启定位图层 mBaiduMap.setMyLocationEnabled(true); mBaiduMap.setMyLocationConfigeration(new MyLocationConfigeration(MyLocationConfigeration.LocationMode.NORMAL, true, null)); // 定位初始化 mLocClient = new LocationClient(this); mLocClient.registerLocationListener(myListener); LocationClientOption option = new LocationClientOption(); option.setProdName("bmobim");// 设置产品线 option.setOpenGps(true);// 打开gps option.setCoorType("bd09ll"); // 设置坐标类型 option.setScanSpan(1000); option.setOpenGps(true); option.setIsNeedAddress(true); option.setIgnoreKillProcess(true); mLocClient.setLocOption(option); mLocClient.start(); if (mLocClient != null && mLocClient.isStarted()) mLocClient.requestLocation(); if (lastLocation != null) { // 显示在地图上 LatLng ll = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); } }
Example #17
Source File: MapActivity.java From BaiduMap-TrafficAssistant with MIT License | 5 votes |
private void initView() { // 获取地图控件引用 mMapView = (MapView) findViewById(R.id.bmapView); // 改变显示的比例尺 mBaiduMap = mMapView.getMap(); MapStatusUpdate after = MapStatusUpdateFactory.zoomTo(15.0f); mBaiduMap.setMapStatus(after); }
Example #18
Source File: EaseBaiduMapActivity.java From Social with Apache License 2.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { if (location == null) { return; } Log.d("map", "On location change received:" + location); Log.d("map", "addr:" + location.getAddrStr()); sendButton.setEnabled(true); if (progressDialog != null) { progressDialog.dismiss(); } if (lastLocation != null) { if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) { Log.d("map", "same location, skip refresh"); // mMapView.refresh(); //need this refresh? return; } } lastLocation = location; mBaiduMap.clear(); LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.ease_icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
Example #19
Source File: EaseBaiduMapActivity.java From Social with Apache License 2.0 | 5 votes |
private void showMap(double latitude, double longtitude, String address) { sendButton.setVisibility(View.GONE); LatLng llA = new LatLng(latitude, longtitude); CoordinateConverter converter= new CoordinateConverter(); converter.coord(llA); converter.from(CoordinateConverter.CoordType.COMMON); LatLng convertLatLng = converter.convert(); OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory .fromResource(R.drawable.ease_icon_marka)) .zIndex(4).draggable(true); mBaiduMap.addOverlay(ooA); MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f); mBaiduMap.animateMapStatus(u); }
Example #20
Source File: MainActivity.java From VirtualLocation with Apache License 2.0 | 5 votes |
/** * setCurrentMapLatLng 设置当前坐标 */ public static void setCurrentMapLatLng(LatLng arg0) { curLatlng = arg0; mMarker.setPosition(arg0); // 设置地图中心点为这是位置 LatLng ll = new LatLng(arg0.latitude, arg0.longitude); MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll); mBaiduMap.animateMapStatus(u); // 根据经纬度坐标 找到实地信息,会在接口onGetReverseGeoCodeResult中呈现结果 mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(arg0)); }
Example #21
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
@Override public void onReceiveLocation(BDLocation location) { if (null != location && location.getLocType() != BDLocation.TypeServerError) { // MyLocationData data = new MyLocationData.Builder()// // .direction(mCurrentX)// .accuracy(location.getRadius())// .latitude(location.getLatitude())// .longitude(location.getLongitude())// .build(); mBaiduMap.setMyLocationData(data); // 设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration( MyLocationConfiguration.LocationMode.NORMAL, true, null); mBaiduMap.setMyLocationConfigeration(config); mAddress = location.getAddrStr(); mName = location.getStreet(); mCity = location.getCity(); LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); mLoactionLatLng = currentLatLng; // 是否第一次定位 if (isFirstLoc) { isFirstLoc = false; // 实现动画跳转 MapStatusUpdate u = MapStatusUpdateFactory .newLatLng(currentLatLng); mBaiduMap.animateMapStatus(u); mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption()) .location(currentLatLng)); return; } } }
Example #22
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public void turnBack() { MyLocationData location = mBaiduMap.getLocationData(); if (location == null) { return; } // 实现动画跳转 MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(new LatLng(location.latitude, location.longitude)); mBaiduMap.animateMapStatus(u); mBaiduMap.clear(); // 发起反地理编码检索 mGeoCoder.reverseGeoCode((new ReverseGeoCodeOption()) .location(new LatLng(location.latitude, location.longitude))); }
Example #23
Source File: MapPickerActivity.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
private void initMap() { //ricky init baidumap begin mMapView = (MapView) findViewById(R.id.bmapView); mBaiduMap = mMapView.getMap(); mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL); mMapView.showZoomControls(false); MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f); mBaiduMap.setMapStatus(msu); mBaiduMap.setOnMapTouchListener(touchListener); // 初始化POI信息列表 mInfoList = new ArrayList<PoiInfo>(); // 初始化当前MapView中心屏幕坐标,初始化当前地理坐标 mCenterPoint = mBaiduMap.getMapStatus().targetScreen; mLoactionLatLng = mBaiduMap.getMapStatus().target; // 定位 mBaiduMap.setMyLocationEnabled(true); // 隐藏百度logo ZoomControl int count = mMapView.getChildCount(); for (int i = 0; i < count; i++) { View child = mMapView.getChildAt(i); if (child instanceof ImageView || child instanceof ZoomControls) { child.setVisibility(View.INVISIBLE); } } // 隐藏比例尺 //mMapView.showScaleControl(false); // 地理编码 mGeoCoder = GeoCoder.newInstance(); mGeoCoder.setOnGetGeoCodeResultListener(GeoListener); list = (ListView) findViewById(R.id.list); list.setOnItemClickListener(this); list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); loading = (ProgressBar) findViewById(R.id.loading); status = (TextView) findViewById(R.id.status); mAdapter = new MapPickerAdapter(MapPickerActivity.this, mInfoList); list.setAdapter(mAdapter); }
Example #24
Source File: MapActivity.java From BaiduMap-TrafficAssistant with MIT License | 4 votes |
@Override public void onReceiveLocation(BDLocation location) { MyLocationData data = new MyLocationData.Builder()// .direction(mCurrentX)// .accuracy(location.getRadius())// .latitude(location.getLatitude())// .longitude(location.getLongitude())// .build(); mBaiduMap.setMyLocationData(data); // 设置自定义图标 MyLocationConfiguration config = new MyLocationConfiguration( mLocationMode, true, mIconLocation); mBaiduMap.setMyLocationConfigeration(config); // 更新经纬度 mLatitude = location.getLatitude(); mLongitude = location.getLongitude(); if (isFirstIn) { LatLng latlng = new LatLng(location.getLatitude(), location.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latlng); mBaiduMap.animateMapStatus(msu); isFirstIn = false; Toast.makeText(context, location.getAddrStr(), Toast.LENGTH_SHORT).show(); Log.i("TAG", location.getAddrStr() + "\n" + location.getAltitude() + "" + "\n" + location.getCity() + "\n" + location.getCityCode() + "\n" + location.getCoorType() + "\n" + location.getDirection() + "\n" + location.getDistrict() + "\n" + location.getFloor() + "\n" + location.getLatitude() + "\n" + location.getLongitude() + "\n" + location.getNetworkLocationType() + "\n" + location.getProvince() + "\n" + location.getSatelliteNumber() + "\n" + location.getStreet() + "\n" + location.getStreetNumber() + "\n" + location.getTime() + "\n"); // 弹出对话框显示定位信息; Builder builder = new Builder(context); builder.setTitle("为您获得的定位信息:"); builder.setMessage("当前位置:" + location.getAddrStr() + "\n" + "城市编号:" + location.getCityCode() + "\n" + "定位时间:" + location.getTime() + "\n" + "当前纬度:" + location.getLatitude() + "\n" + "当前经度:" + location.getLongitude()); builder.setPositiveButton("确定", null); AlertDialog alertDialog = builder.create(); alertDialog.show(); }// if }
Example #25
Source File: MainActivity.java From MoveMapLocation with Apache License 2.0 | 4 votes |
/** * 定位监听 * * @param bdLocation */ @Override public void onReceiveLocation(BDLocation bdLocation) { //如果bdLocation为空或mapView销毁后不再处理新数据接收的位置 if (bdLocation == null || mBaiduMap == null) { return; } //定位数据 MyLocationData data = new MyLocationData.Builder() //定位精度bdLocation.getRadius() .accuracy(bdLocation.getRadius()) //此处设置开发者获取到的方向信息,顺时针0-360 .direction(bdLocation.getDirection()) //经度 .latitude(bdLocation.getLatitude()) //纬度 .longitude(bdLocation.getLongitude()) //构建 .build(); //设置定位数据 mBaiduMap.setMyLocationData(data); //是否是第一次定位 if (isFirstLoc) { isFirstLoc = false; LatLng ll = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLngZoom(ll, 18); mBaiduMap.animateMapStatus(msu); } //获取坐标,待会用于POI信息点与定位的距离 locationLatLng = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude()); //获取城市,待会用于POISearch city = bdLocation.getCity(); //文本输入框改变监听,必须在定位完成之后 searchAddress.addTextChangedListener(this); //创建GeoCoder实例对象 geoCoder = GeoCoder.newInstance(); //发起反地理编码请求(经纬度->地址信息) ReverseGeoCodeOption reverseGeoCodeOption = new ReverseGeoCodeOption(); //设置反地理编码位置坐标 reverseGeoCodeOption.location(new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude())); geoCoder.reverseGeoCode(reverseGeoCodeOption); //设置查询结果监听者 geoCoder.setOnGetGeoCodeResultListener(this); }
Example #26
Source File: MainActivity.java From MoveMapLocation with Apache License 2.0 | 4 votes |
private void initView() { mMapView = (MapView) findViewById(R.id.main_bdmap); mBaiduMap = mMapView.getMap(); poisLL = (ListView) findViewById(R.id.main_pois); topRL = (RelativeLayout) findViewById(R.id.main_top_RL); searchAddress = (EditText) findViewById(R.id.main_search_address); searchPois = (ListView) findViewById(R.id.main_search_pois); //定义地图状态 MapStatus mMapStatus = new MapStatus.Builder().zoom(18).build(); MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus); //改变地图状态 mBaiduMap.setMapStatus(mMapStatusUpdate); //地图状态改变相关监听 mBaiduMap.setOnMapStatusChangeListener(this); //开启定位图层 mBaiduMap.setMyLocationEnabled(true); //定位图层显示方式 mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL; /** * 设置定位图层配置信息,只有先允许定位图层后设置定位图层配置信息才会生效 * customMarker用户自定义定位图标 * enableDirection是否允许显示方向信息 * locationMode定位图层显示方式 */ mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, null)); //初始化定位 mLocClient = new LocationClient(this); //注册定位监听 mLocClient.registerLocationListener(this); //定位选项 LocationClientOption option = new LocationClientOption(); /** * coorType - 取值有3个: * 返回国测局经纬度坐标系:gcj02 * 返回百度墨卡托坐标系 :bd09 * 返回百度经纬度坐标系 :bd09ll */ option.setCoorType("bd09ll"); //设置是否需要地址信息,默认为无地址 option.setIsNeedAddress(true); //设置是否需要返回位置语义化信息,可以在BDLocation.getLocationDescribe()中得到数据,ex:"在天安门附近", 可以用作地址信息的补充 option.setIsNeedLocationDescribe(true); //设置是否需要返回位置POI信息,可以在BDLocation.getPoiList()中得到数据 option.setIsNeedLocationPoiList(true); /** * 设置定位模式 * Battery_Saving * 低功耗模式 * Device_Sensors * 仅设备(Gps)模式 * Hight_Accuracy * 高精度模式 */ option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy); //设置是否打开gps进行定位 option.setOpenGps(true); //设置扫描间隔,单位是毫秒 当<1000(1s)时,定时定位无效 option.setScanSpan(1000); //设置 LocationClientOption mLocClient.setLocOption(option); //开始定位 mLocClient.start(); }
Example #27
Source File: BaiduMapFragment.java From BmapLite with GNU General Public License v3.0 | 4 votes |
public void animateMapStatus(MapStatusUpdate mapStatusUpdate) { mBaiduMap.animateMapStatus(mapStatusUpdate); }
Example #28
Source File: MapActivity.java From BaiduMap-TrafficAssistant with MIT License | 4 votes |
private void centerToMyLocation() { LatLng latlng = new LatLng(mLatitude, mLongitude); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latlng); mBaiduMap.animateMapStatus(msu); }
Example #29
Source File: MainActivity.java From Mobike with Apache License 2.0 | 4 votes |
public void getMyLocation() { isNeedCurrentlocation = true; LatLng latLng = new LatLng(currentLatitude, currentLongitude); MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng); baiduMap.setMapStatus(msu); }
Example #30
Source File: MapFragment.java From apollo-DuerOS with Apache License 2.0 | 4 votes |
private void initMap() { // Set the enlargement and reduction button mMapView.setMapCustomEnable(true); View child = mMapView.getChildAt(1); // delete logo if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) { child.setVisibility(View.INVISIBLE); // ((ImageView)child).setImageDrawable(getResources().getDrawable(R.drawable.app)); } mMapView.showZoomControls(false); mMapView.showScaleControl(false); mBaiduMap = mMapView.getMap(); // Open the location layer mBaiduMap.setMyLocationEnabled(true); // Close the traffic map mBaiduMap.setTrafficEnabled(false); mBaiduMap.setBaiduHeatMapEnabled(false); mBaiduMap.setIndoorEnable(false); mBaiduMap.setBuildingsEnabled(false); mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING; mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker)); // set custom logo // Modify it to custom marker mCurrentMarker = BitmapDescriptorFactory .fromResource(R.drawable.car_point); mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration( mCurrentMode, true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor)); mCurrentLat = MapSdkWrapper.getLatitudeBd09ll(); mCurrentLon = MapSdkWrapper.getLongitudeBd09ll(); // set the direction information that developers get,clockwise:0-360 locData = new MyLocationData.Builder().accuracy(mCurrentAccracy) .direction((float) direction).latitude(mCurrentLat).longitude(mCurrentLon).build(); mBaiduMap.setMyLocationData(locData); LatLng ll = new LatLng(mCurrentLat, mCurrentLon); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(ll); MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5); mBaiduMap.animateMapStatus(u); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mBaiduMap.setOnMapRenderCallbadk(onMapRenderCallback); LogUtil.i(TAG, "Map is init"); }