如何获得地图边界?

how to get the map bounds?

我正在从 leaflet 迁移回来,如果我需要地图绑定,我使用以下代码:

var b = map.getBounds();
$scope.filtromapa.lat1 = b.getSouth();
$scope.filtromapa.lat2 = b.getNorth();
$scope.filtromapa.lng1 = b.getWest();
$scope.filtromapa.lng2 = b.getEast();

那些有效 latitude/longitude 位置的值因此我可以将它发送到我的后端并查询该区域内的任何位置。

我如何使用 openlayers 做到这一点?

现在我只有:

var b = map.getView().calculateExtent(map.getSize());

但是这些位置无效 latitude/longitude 个位置。

我正在使用 openlayers 3.19.1

遵循 https://gis.stackexchange.com/questions/122250/how-to-get-the-feature-location-in-openlayers-v3 的答案(及其假设

var currentExtent = map.getView().calculateExtent(map.getSize()),
    TLpoint = ol.extent.getTopLeft( currentExtent ),
    BRpoint = ol.extent.getBottomRight( currentExtent ),
    TLcoords = ol.proj.transform( TLpoint, 'EPSG:3857', 'EPSG:4326' ),
    BRcoords = ol.proj.transform( BRpoint, 'EPSG:3857', 'EPSG:4326' );