如何更改谷歌地图Android版V2信息窗口(自定义)位置? [英] How to change Info-window (custom) Position in google map v2 android?

查看:164
本文介绍了如何更改谷歌地图Android版V2信息窗口(自定义)位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个谷歌地图的屏幕,在屏幕上方有搜索代替一个AutotextView,并进行了定制的信息窗口中显示更多的细节,问题是,当任何标记自定义窗口弹出作为其默认搜索行为的用户点击(中心在屏幕上),所以混了autotextview,我可以改变一样,在屏幕上的信息窗口的位置,即底部或任何东西。

I have a screen with google map, on top of screen there is one AutotextView for search place, and make a custom info window to show more details, problem is when user click on any mark custom window popup as their default behaviour (center on screen), so it mixed up autotextview, Can I change info-window position on screen, i.e bottom or anything like that.

推荐答案

如果您想调整谷歌地图屏幕弹出的标记位置完美的中心,那么请在使用低于code,我有得到弹出高度,并基于该更新Ÿaxis.i希望它会帮助你。

If you want to adjust Marker location perfect center on google map screen with popup then please use below code in that i have get popup height and based on that update y axis.i hope it will help you.

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版V2信息窗口(自定义)位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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