放大到仍然显示所有标记最接近的水平,其中包括蓝色MyLocation标记 [英] Zoom to the closest level that still shows all markers, including the blue MyLocation marker

查看:164
本文介绍了放大到仍然显示所有标记最接近的水平,其中包括蓝色MyLocation标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想缩放和位置我的的GoogleMap ,使得所有的标记,包括蓝色 MyLocation 标记,是可见。 这太问题说明如何为所有这样做手动添加标记,但我不知道如何获得一个句柄 MyLocation 标记,这是打完电话后 setMyLocationEnabled(真),以便将其传递给 LatLngBounds.Builder

I would like to zoom and position my GoogleMap such that all markers, including the blue MyLocation marker, are visible. This SO question shows how to do this for all manually added markers, but I am not sure how to get a handle to the MyLocation marker, which is automatically added after calling setMyLocationEnabled(true), in order to pass it to the LatLngBounds.Builder.

我已经尝试使用 GoogleMap.getMyLocation(),而我称其为 onPostCreate ,地图后已完全初始化。调用返回虽然。 这SO回答了解一个bug与会谈getMyLocation(),但还提到,它是固定的。

I have tried using GoogleMap.getMyLocation(), and I am calling it in onPostCreate, after the map has been fully initialized. The call returns null though. This SO answer talks about a bug with getMyLocation(), but also mentions that it was fixed.

推荐答案

要添加到我的位置经纬度蓝点,使用 GoogleMap的。 getMyLocation()或者如果你想每次更新相机的位置变化, GoogleMap.setOnMyLocationChangeListener(...),然后再转换位置经纬度

To add to that LatLng of my location blue dot, use GoogleMap.getMyLocation() or if you want to update camera every time that location changes, GoogleMap.setOnMyLocationChangeListener(...) and then convert Location to LatLng.

这篇关于放大到仍然显示所有标记最接近的水平,其中包括蓝色MyLocation标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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