android - (谷歌地图)检查 LatLng 是否在可见区域经度的 80% 以内
问题描述
LinearLayout
我有一个 android 布局,它有一个谷歌地图布局,底部覆盖了一个小地图。当用户选择地图上的标记时,这个小布局变得可见。现在,我想知道所选标记是否在选择时被小布局覆盖,比如它是否在地图经度可见区域的前 80% 范围内。我玩过,maps.getProjection().getVisibleRegion()
但我不确定我从这里去哪里。提前致谢
解决方案
确认地图已加载后,请尝试以下操作:
LatLngBounds.Builder builder = new LatLngBounds.Builder();
LatLngBounds bounds = builder.build();
LatLng ne = bounds.northeast;
LatLng sw = bounds.southwest;
Point neBoundInPx = mGoogleMap.getProjection().toScreenLocation(ne);
Point swBoundInPx = mGoogleMap.getProjection().toScreenLocation(sw);
Point newBottomBoundInPx = new Point (neBoundInPx.x , swBoundInPx.y - bottomLinearLayout.getHeight());
LatLng newBottomBoundInPxLatLng = mGoogleMap.getProjection().fromScreenLocation(newBottomBoundInPx);
if(placeLatLng.latitude <= ne.latitude &&
placeLatLng.longitude >= sw.longitude &&
placeLatLng.latitude >= newBottomBoundInPxLatLng.latitude &&
placeLatLng.longitude <= ne.longitude) {
//Yor place is above the linearLayout at the Bottom.
}
推荐阅读
- android - 有没有办法使用 declare-styleable 打开选择资源对话框,让您在 Android Studio 中选择颜色或可绘制对象?
- regex - 如何将所有非单词字符更改为破折号并在一个正则表达式中修剪破折号字符串?
- python - python 如何从 2019 年 12 月和两个日期列之间查找每个月的天数
- python - 如何在 Python 中向字典键添加多个值
- group-by - 根据 Google Big Query 中的案例分组和求和
- ssas - SSAS - 向事实表添加新字段而不会出错
- python - 使用 jquery/ajax 显示来自服务器的 JSON 数据
- javascript - 仅为特定表格添加表格行
- javascript - VS 代码高亮 Angular 6 中的 jasmine 函数
- node.js - 为什么从数据库调用返回的对象只能使用一次?