放大到仍然显示所有标记最接近的水平,其中包括蓝色MyLocation标记 [英] Zoom to the closest level that still shows all markers, including the blue MyLocation marker
问题描述
我想缩放和位置我的的GoogleMap
,使得所有的标记,包括蓝色 MyLocation
标记,是可见。 这太问题说明如何为所有这样做手动添加标记,但我不知道如何获得一个句柄 MyLocation
标记,这是打完电话后 setMyLocationEnabled(真)自动添加code>,以便将其传递给
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屋!