使用不同的填充设置地图边界 [英] Set Map Bounds with different padding

查看:107
本文介绍了使用不同的填充设置地图边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有什么方法可以从Device的每个站点为Google地图范围设置不同的填充.

I want to know if ther is any way of set different padding from each site of the Device for Google maps bounds.

因为我有一个mpview巫婆可以匹配整个活动,但是我在屏幕的底部1/3处有一个MapOverlay(linerar版面中的一些Text,没有非过渡背景).

Because I have an mpview witch match the whole activity, but I have a MapOverlay (some Text inside a linerar Layout with non transulent background) on the bottom 1/3 off the screen.

现在我想使用地图范围进行放大.但是它应该从底部开始有更多的填充,这样它才不会落后于我的mapOverlay.

And now i want to zoom in by using map bounds. But it should have more padding from the bottom so it didn't get behind my mapOverlay.

我将此代码与120填充一起使用.

I use this code with the padding of 120.

final com.google.android.gms.maps.model.LatLngBounds.Builder bounds = new LatLngBounds.Builder();
bounds.include(pref.getSavedLatLng());
bounds.include(currentLatLng);
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), 120));

是否有任何方法可以设置不同的填充,或针对此问题的其他解决方案?

Is there any way of setting different paddings, or other solution for this problem?

谢谢您的帮助,对不起我的英语.

Thank you for helping and sorry for my english.

推荐答案

这是一个较旧的问题,也许问问者已找到解决方案,但这是给将来遇到相同问题的任何人的.使用

googleMap.setPadding(left, top, right, bottom)

设置单个填充,然后使用

googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), 0))

完成后,别忘了将填充设置回0(或之前的填充).因为与newLatLngBounds()不同,由setPadding()设置的填充是永久的.

This is an older question and maybe the asker found the solution but here it is for anyone who faces same problem in future. Set the individual padding using

googleMap.setPadding(left, top, right, bottom)

and then use

googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds.build(), 0))

Don't forget to set the paddings back to 0 (or whatever they were before) after you are done. Because unlike newLatLngBounds(), the paddings set by setPadding() are permanent.

这篇关于使用不同的填充设置地图边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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