【发布时间】:2018-02-13 09:08:03
【问题描述】:
当蓝色飞镖在 android 谷歌地图上移动时,我想获得纬度和经度值。 基本上,我想以高精度获取手机的当前位置,并在位置变化时立即更新。
但是 LocationListener 不经常调用方法 onLocationChanged(),这就是为什么我没有得到最新的位置值。
我尝试了许多其他可能性来获得一个具有高精度和经常更新值的位置。
我搜索并发现已弃用的 Fused Location API。
我没有找到他们解决问题以获得频繁和最新位置值的任何网站。
如果我将获得蓝色飞镖位置值,那么我认为我的问题将得到解决。
代码:
@Override
public void onMapReady(GoogleMap googleMap) {
Log.d(TAG, "onMapReady() method called");
mMap = googleMap;
mMap.getUiSettings().setZoomControlsEnabled(true);
if (checkPermission())
mMap.setMyLocationEnabled(true);
mMap.setOnMyLocationButtonClickListener(this);
mMap.setOnMyLocationClickListener(this);
View locationButton = ((View) mapFragment.getView().findViewById(Integer.parseInt("1")).
getParent()).findViewById(Integer.parseInt("2"));
RelativeLayout.LayoutParams rlp = (RelativeLayout.LayoutParams) locationButton.getLayoutParams();
rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
if (locationGlobal != null) updateMarker(locationGlobal);
}
【问题讨论】:
-
locationchanged 仅在满足定义的距离或定义的时间条件时调用。
-
inside on location changed get current location lat long and u can get current lat long.
标签: android google-maps android-location