目标:根据百度地图开发者文档,编写百度地图定位程序。在地图上标出所在的位置。
首先从官网下载SDK然后导入
然后是JAVA文件中代码,定位监听函数等
public class MyLocationListener extends BDAbstractLocationListener {
@Override
public void onReceiveLocation(BDLocation location) {
//mapView 销毁后不在处理新接收的位置
if (location == null || mMapView == null){
return;
}
MyLocationData locData = new MyLocationData.Builder()
.accuracy(location.getRadius())
// 此处设置开发者获取到的方向信息,顺时针0-360
.latitude(location.getLatitude())
.longitude(location.getLongitude())
.direction(location.getDirection())
.build();
mBaiduMap.setMyLocationData(locData);
MyLocationConfiguration configuration = new MyLocationConfiguration(
MyLocationConfiguration.LocationMode.NORMAL, false, mMarker);
mBaiduMap.setMyLocationConfiguration(configuration);
跑起来的样子:
最后是源码
本文地址:https://blog.csdn.net/Sunday_bu/article/details/106339706
如对本文有疑问, 点击进行留言回复!!
第三次学JAVA再学不好就吃翔(part88)--ArrayList嵌套ArrayList
使用ffmpeg视频切片并加密和视频AES-128加密后播放
JAVA程序设计:最长重复子串(LeetCode:1044)
LiveGBS国标GB/T28181云端录像分布式录像存储自动清理时移回看录像下载播放
网友评论