gpt4 book ai didi

android - 如何在 google map v2 android 中更改信息窗口(自定义)位置?

转载 作者:太空狗 更新时间:2023-10-29 16:38:46 24 4
gpt4 key购买 nike

我有一个带有谷歌地图的屏幕,在屏幕顶部有一个 AutotextView 用于搜索位置,并制作一个自定义信息窗口以显示更多详细信息,问题是当用户点击任何标记自定义窗口弹出窗口作为他们的默认行为时(在屏幕上居中),所以它混淆了 autotextview,我可以更改信息窗口在屏幕上的位置吗,即底部或类似的东西。

最佳答案

如果你想用弹出窗口调整谷歌地图屏幕上的标记位置完美居中,那么请使用下面的代码,因为我已经获得了弹出高度并基于该更新 y 轴。我希望它能帮助你.

public boolean onMarkerClick(Marker marker) {

//Please use fix height popup
float container_height = getResources().getDimension(R.dimen.DIP_300);

Projection projection = mGoogleMap.getProjection();

Point markerScreenPosition = projection.toScreenLocation(marker.getPosition());
Point pointHalfScreenAbove = new Point(markerScreenPosition.x,(int) (markerScreenPosition.y - (container_height / 2)));

LatLng aboveMarkerLatLng = projection.fromScreenLocation(pointHalfScreenAbove);

marker.showInfoWindow();
CameraUpdate center = CameraUpdateFactory.newLatLng(aboveMarkerLatLng);
mGoogleMap.moveCamera(center);
mGoogleMap.animateCamera(center);
marker.showInfoWindow();

return true;


}

关于android - 如何在 google map v2 android 中更改信息窗口(自定义)位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21678545/

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