【问题标题】:Defining a CameraUpdate with LatLngBounds with different padding values使用具有不同填充值的 LatLngBounds 定义 CameraUpdate
【发布时间】:2014-02-23 15:24:15
【问题描述】:

是否有允许为MapFragment的不同边缘指定默认填充值的函数,即类似于

CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds, int padding)

已经存在,但是类似于

CameraUpdateFactory.newLatLngBounds(LatLngBounds bounds, int paddingTop, int paddingLeft, int paddingBottom, int paddingRight)?

为什么我需要这个:在我的 MapFragment 顶部有一个半透明层。因此,我需要在顶部比底部更宽的填充。

我发现了类似的问题:Offseting the center of the MapFragment for an animation moving both the target lat/lng and the zoom level。但是,在我的情况下,获得 X 像素的投影和滚动是不够的,因为我不仅想滚动(平移)。我使用带有 newLatLngBounds(bounds, padding) 的 CameraUpdate,它应该 both 缩放 平移。所以在相机更新之前我有一个不同的投影。

希望我把问题说清楚了!

【问题讨论】:

  • 您是否尝试过使用GoogleMap.setPadding
  • 就是这样,谢谢!!我应该更仔细地阅读文档;)请作为答案发布,以便我接受...

标签: android google-maps google-maps-android-api-2


【解决方案1】:

这是一个将填充设置为映射的示例...

在地图上设置填充。

此方法允许您在地图上定义一个可见区域,通过在地图的四个边缘中的每一个上设置填充来向地图发出信号,表明边缘周围的地图部分可能会被遮挡。地图功能将适应填充。例如,缩放控件、指南针、版权声明和 Google 徽标将被移动以适应定义的区域,相机移动将相对于可见区域的中心等。

*大小以像素为单位

GoogleMap.setPadding(     10,      20,      20,     50);

    所有都是整数                                                                                                                                                                                                                                                              却则是整型

来自@MaciejGorsky,这是文档...

https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap?hl=pl#setPadding(int, int, int, int)

【讨论】:

    猜你喜欢
    • 2017-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-24
    • 2012-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多