越来越纬度经度0.0从googleMap.getCameraPosition()。目标 [英] getting latitude longitude 0.0 from googleMap.getCameraPosition().target

查看:355
本文介绍了越来越纬度经度0.0从googleMap.getCameraPosition()。目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让纬度地图的中心和纬度。我使用的片段显示地图就是

I was trying to get latitude and longitude of center of the map. I am using Fragment to show map that is,

SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
                                    .findFragmentById(R.id.mapID);
if (fm != null) {
    googleMap = fm.getMap();
}
LatLng loc = googleMap.getCameraPosition().target;

我打印这个禄和我得到的价值为0.0,0.0。我没有得到我要去的地方错了。

I am printing this loc and i am getting value as 0.0, 0.0. I am not getting where i am going wrong.

我试图用 VisibleRegion 也得到纬度地图,甚至是中心没有帮助和经度。

I tried to use VisibleRegion also to get latitude and longitude of center of map but even that did not help.

推荐答案

您所请求的摄像机位置时,地图上还没有装,因此相机指向0.0,0.0。相反,使用这样的:

You are requesting the camera position when the map was not yet loaded, therefore the camera is pointing to 0.0, 0.0. Instead use this:

googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
    @Override
    public void onMapLoaded() {
        Log.e("TAG", googleMap.getCameraPosition().target.toString());
    }
});

这篇关于越来越纬度经度0.0从googleMap.getCameraPosition()。目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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