Check if marker is in view (map) - mapbox(检查标记是否在视图中(地图) - mapbox)
问题描述
我想检查标记是在地图视图上还是在地图外.我正在放置地图的标记,但无法检查它是否在 currentView 上.我试过下面的代码.this.map.getBounds().contains(e.layer.getLatLng());但它让我回归真实.地图正在返回其旧的 lat lng,即边界(我认为是这样)
I want to check if marker is on mapview or out of the map. I am putting marker of the map and not able to check if it on currentView or not. I have tried below code. this.map.getBounds().contains(e.layer.getLatLng()); but it is returning me true. map is returning its old lat lng i.e bounds (I think so)
推荐答案
map.getBounds().contains(myMarker.getLatLng())
map.getBounds()
:返回当前地图视图的 LatLngBounds.
map.getBounds()
: Returns the LatLngBounds of the current map view.
latLngBounds.contains()
:如果矩形包含给定点,则返回 true
.
myMarker.getLatLng()
:返回标记的当前地理位置.
myMarker.getLatLng()
: Returns the current geographical position of the marker.
另请参阅:地图视点中的区域估计使用传单
这篇关于检查标记是否在视图中(地图) - mapbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:检查标记是否在视图中(地图) - mapbox


基础教程推荐
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01