【问题标题】:Get latitude longitude when blue dot moves on google maps当蓝点在谷歌地图上移动时获取纬度经度
【发布时间】: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


【解决方案1】:

试试this,它会在地图上追踪位置... onLocationChanged(Location location) 方法在位置发生变化时调用

【讨论】:

  • 我试过了,但仍然没有经常获得位置值。实际上,这段代码没有调用 onLocationChange 方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多