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

查看:190
本文介绍了检查标记是否在视图(地图)中-Mapbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检查标记是在地图视图上还是在地图之外. 我正在放置地图标记,并且无法检查它是否在currentView上.我试过下面的代码. this.map.getBounds().contains(e.layer.getLatLng()); 但这使我成真. 地图正在返回其旧的纬度(即我认为的范围)

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() :如果矩形包含给定点.

latLngBounds.contains(): Returns true if the rectangle contains the given point.

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

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

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

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

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