gpt4 book ai didi

android - 移动相机位置以适应关于标记高度的 LatLngBounds

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:44:06 24 4
gpt4 key购买 nike

我想将相机移动到适合 LatLngBounds 标记高度的位置。到目前为止,我可以使用以下代码来匹配标记的 anchor :

LatLngBounds.Builder builder = new LatLngBounds.Builder();
for (Marker marker : markerList) {
builder.include(marker.getPosition());
}
LatLngBounds bounds = builder.build();

int padding = getActivity().getResources().getDimensionPixelSize(R.dimen.home_map_padding); // offset from edges of the map in pixels
cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);
mGoogleMap.animateCamera(cameraUpdate);

它产生这样的输出: my output so far如您所见,底部有空白区域(这是 int padding)。 我希望填充像这样相等:

enter image description here

最佳答案

您的问题与此处发布的问题类似:

Defining a CameraUpdate with LatLngBounds with different padding values

解决方案是将实际 GoogleMap 的顶部填充设置为标记图标的高度。

像这样的事情会做:

Drawable drawable = <YOUR DRAWABLE HERE>;
final int padding = drawable.getIntrinsicHeight();
map.setPadding(0, padding, 0, 0);

我的自定义标记图像看起来像这样(插入标尺以进行比较):

enter image description here

关于android - 移动相机位置以适应关于标记高度的 LatLngBounds,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28813371/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com