使用传单捕获 window 纬度、经度
Capture window Lat, Longs with Leaflet
我正在尝试弄清楚如何捕捉传单的四个角 window,以便我可以根据用户在地理上放大的位置加载点。例如,看看 here。
现在,我将如何捕获该视图的四个角,以便我可以只加载在几何上与该一般位置(伦敦市中心)相关的点?
我没能找到 Leaflet 的具体例子。任何帮助将不胜感激。
您应该搜索的术语是 "bounds"。 Leaflet 的 L.Map
有一个名为 getBounds
的方法,它将 return 当前 mapview 的边界:
http://leafletjs.com/reference.html#map-getbounds
Returns the LatLngBounds of the current map view.
它 return 是一个 LatLngBounds
对象,由西南和东北 LatLng 对象组成:
http://leafletjs.com/reference.html#latlngbounds
Represents a rectangular geographical area on a map.
如何使用这些界限从服务器查询兴趣点取决于您使用的平台。
如果您已经加载了一个数据集,并且您想要根据当前边界进行过滤,您可以使用 LatLngBounds
对象的 contains
方法。您可以使用它来检查一个点是否包含在当前范围内:
http://leafletjs.com/reference.html#latlngbounds-contains
Returns true if the rectangle contains the given point.
我正在尝试弄清楚如何捕捉传单的四个角 window,以便我可以根据用户在地理上放大的位置加载点。例如,看看 here。
现在,我将如何捕获该视图的四个角,以便我可以只加载在几何上与该一般位置(伦敦市中心)相关的点?
我没能找到 Leaflet 的具体例子。任何帮助将不胜感激。
您应该搜索的术语是 "bounds"。 Leaflet 的 L.Map
有一个名为 getBounds
的方法,它将 return 当前 mapview 的边界:
http://leafletjs.com/reference.html#map-getbounds
Returns the LatLngBounds of the current map view.
它 return 是一个 LatLngBounds
对象,由西南和东北 LatLng 对象组成:
http://leafletjs.com/reference.html#latlngbounds
Represents a rectangular geographical area on a map.
如何使用这些界限从服务器查询兴趣点取决于您使用的平台。
如果您已经加载了一个数据集,并且您想要根据当前边界进行过滤,您可以使用 LatLngBounds
对象的 contains
方法。您可以使用它来检查一个点是否包含在当前范围内:
http://leafletjs.com/reference.html#latlngbounds-contains
Returns true if the rectangle contains the given point.