谷歌Android地图API V2,得到的坐标为当前地图中心 [英] Android Google Maps Api V2, getting the coordinates for the current map center

查看:124
本文介绍了谷歌Android地图API V2,得到的坐标为当前地图中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌Android地图API V2(不图形页面或MapActivity),我有困难得到的坐标为地图中央。

我想用

  @覆盖
公共无效onCameraChange(CameraPosition为arg0){
    // TODO自动生成方法存根
    地理codeCenter(/ * Location对象* /);
}
 

但我不能从CameraPosition对象获取的纬度/长。该相机还具有更多的维度,你可以看看地图,在不同的音高,现在也一样,所以得到的纬度中心/经度是不一样的,因为用户不能保证在看从鸟瞰地图,除非某些手势被禁用。

有没有更好的方式来做到这一点?我不希望用户必须长时间点击一个标记,以将其拖动地图的时候,我希望他们只知道地图的中心是围绕平移的用户。

map.getMyLocation()方法是别的东西,像目前LocationProvider位置。也不看似选项,尽管事实上,我现在用的GPS,它仍然返回null

解决方案
  

但我无法得到纬度/经度从CameraPosition对象

的<一个href="https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/CameraPosition#target"><$c$c>target公共数据成员一个 CameraPosition 经纬度的地图中心,根据我读的文档。

I am using Android Google Maps Api V2 (not MapView or MapActivity) and I am having difficulty getting the coordinates for the center of the map.

I was thinking of using

@Override
public void onCameraChange(CameraPosition arg0) {
    // TODO Auto-generated method stub
    geoCodeCenter(/*Location object*/);
}

but I can't get the lat/long from the CameraPosition object. the camera also has more dimensions as you can look at the map at different pitches now too, so getting the center of for latitude/longitude isn't the same since the user isn't guaranteed to be looking at the map from birds eye view, unless certain gestures are disabled.

Is there a better way to do this? I don't want the user to have to long click a marker to drag it around the map, I want them to just know where the center of the map is by the user panning it around.

the map.getMyLocation() method is for something else, like the current LocationProvider position. Also not seemingly the option, notwithstanding the fact that I am using GPS and it still returns null

解决方案

but I can't get the lat/long from the CameraPosition object

The target public data member on a CameraPosition is a LatLng of the map center, based upon my reading of the docs.

这篇关于谷歌Android地图API V2,得到的坐标为当前地图中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆