我想检查标记是在地图视图上还是在地图外.我正在放置地图的标记,但无法检查它是否在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
检查一个多边形点是否在传单中的另一个内部Check if a polygon point is inside another in leaflet(检查一个多边形点是否在传单中的另一个内部)
更改传单标记群集图标颜色,继承其余默认 CSSChanging leaflet markercluster icon color, inheriting the rest of the default CSS properties(更改传单标记群集图标颜色,继承其余默认
触发点击传单标记Trigger click on leaflet marker(触发点击传单标记)
如何更改 LeafletJS 中的默认加载磁贴颜色?How can I change the default loading tile color in LeafletJS?(如何更改 LeafletJS 中的默认加载磁贴颜色?)
将外部geojson添加到传单层Add external geojson to leaflet layer(将外部geojson添加到传单层)
将 Leaflet 图层控件添加到侧边栏Adding Leaflet layer control to sidebar(将 Leaflet 图层控件添加到侧边栏)