android - 我需要一个蓝点位置,没有 location.getLatitude/Longtitude
问题描述
我有个问题。我的应用程序使用坐标在后续位置之间绘制路径:第一个位置到第二个位置,第二个到第三个位置等。该应用程序绘制路径没有问题,但我的位置有噪音,而且线条无处不在。我知道谷歌地图上的蓝点正在使用平滑算法、不同的位置提供程序和其他调整。我可以获取这个默认蓝点的坐标吗?没有算法就不是法线坐标。
public void onMapReady(GoogleMap map) {
mMap = map;
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
mMap.setMyLocationEnabled(true);
lokalizacja();
} else {
ActivityCompat.requestPermissions(WorkoutActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MY_LOCATION_REQUEST_CODE);
}
routeOpts = new PolylineOptions()
.color(Color.BLUE)
.width(5 /* TODO: respect density! */)
.geodesic(true);
route = mMap.addPolyline(routeOpts);
route.setVisible(drawTrack);
mMap.setOnMyLocationButtonClickListener(this);
mMap.setOnMyLocationClickListener(this); }
public void lokalizacja() { //Context context = getApplicationContext();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
if (routeOpts != null) {
lat = (float) location.getLatitude();
lng = (float) location.getLongitude();
LatLng myLatLng = new LatLng(lat, lng);
List<LatLng> points = route.getPoints();
points.add(myLatLng);
route.setPoints(points);
}
}
@Override public void onStatusChanged(String provider, int status, Bundle extras) {
Log.d("tocos","StatusChanged");
}
@Override
public void onProviderEnabled(String provider) {
Log.d("tocos","Enabled");
}
@Override
public void onProviderDisabled(String provider) {
Log.d("tocos","Disabled");
}
};
解决方案
我认为您想要的是使用Google Play 服务而不是操作系统附带FusedLocationProvider
的内置服务。LocationManager
看看这个答案,它非常详细地解释了它
推荐阅读
- microsoft-graph-api - Microsoft Graph API - 外出自动回复
- javascript - 如何更改构造函数的一个属性而不影响其他属性?
- maven - ErrorPageFilter - 由于异常 [java.lang.NullPointerException] 从请求 [/mypath] 转发到错误页面
- c# - 当我尝试运行测试时没有可用的源
- openlayers - 如何从openlayer中删除标记?
- javascript - firebase“长链接不可解析”
- c# - Unity PauseMenu 在第二级不起作用
- ssis - 提取括号中的字符串 - SSIS
- azure - 发布到 Azure 后,机器人没有响应
- python - Python:比较两个可能有噪音的音频文件