检查标记是否在视图中(地图) - mapbox [英] Check if marker is in view (map) - mapbox

查看:26
本文介绍了检查标记是否在视图中(地图) - 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(): Returns the LatLngBounds of the current map view.

latLngBounds.contains():如果矩形包含给定点,则返回 true.

myMarker.getLatLng():返回标记的当前地理位置.

myMarker.getLatLng(): Returns the current geographical position of the marker.

另请参阅:地图视点中的区域估计使用传单

这篇关于检查标记是否在视图中(地图) - mapbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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