获取放大地图的位置:传单 [英] Get Position on zooming in map : leaflet

查看:76
本文介绍了获取放大地图的位置:传单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用传单方面还很陌生.有人可以告诉我我可以完成缩放的区域的经度和纬度吗?以及我怎么知道那个区域有多少物体?

I am fairly new in using leaflet. Can someone tell me that can I get longitude and latitude of the area where I have finished zooming? and How can I know how many objects are in that area?

推荐答案

首先,您需要捕获zoomend事件,在事件对象内部将是地图实例,您可以从中获取boundingBox.
然后为您检查每个图层是否在bbox中.

First you need to catch zoomend event, inside an event object will be map instance, from which you can get boundingBox.
Then for you check each layer is it inside bbox.

map.on('zoomend',function(e){
  var map = e.target,
  bounds = map.getBounds();
  map.eachLayer(function(layer){
    if(bounds.contains(layer.getBounds()))
      alert('kek');
  }); 
})

这篇关于获取放大地图的位置:传单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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