Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get markers only on viewable area of map #1167

Open
amalfernando opened this issue Feb 3, 2017 · 1 comment
Open

Get markers only on viewable area of map #1167

amalfernando opened this issue Feb 3, 2017 · 1 comment

Comments

@amalfernando
Copy link

Hi,
Is it possible get markers within the view able area when zoom in/out or when map move?

I use version : 0.7.11 on Ionic 1 app.

Thanks

@yukk1
Copy link

yukk1 commented Feb 17, 2017

Use map.getBounds().contains(L.latLng())

$scope.$watch('bounds', function(){
  leafletData.getMap().then(function(map){
    $scope.markersWithinBounds = $scope.markers.filter(function(marker){
      return map.getBounds().contains(L.latLng(marker.lat, marker.lng));
    });
  })
});

plunker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants