Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if marker is in view (map) - mapbox

enter image description hereI 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)

like image 947
Kalashir Avatar asked May 17 '16 07:05

Kalashir


1 Answers

map.getBounds().contains(myMarker.getLatLng())

  • map.getBounds(): Returns the LatLngBounds of the current map view.

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

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

See also: area estimation in viewpoint of map using leaflet

like image 148
ghybs Avatar answered Nov 05 '22 09:11

ghybs