【问题标题】:how to get the map bounds?如何获得地图边界?
【发布时间】:2016-11-06 01:02:42
【问题描述】:

我正在从传单迁移,然后如果我需要地图绑定,我使用以下代码:

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

那些有效纬度/经度位置的值,因此我可以将其发送到我的后端并查询该区域内的任何位置。

如何使用 openlayers 做到这一点?

现在我只有:

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

但是这些位置不是有效的纬度/经度位置。

我正在使用 openlayers 3.19.1

【问题讨论】:

    标签: javascript leaflet openlayers-3


    【解决方案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' );
    

    【讨论】:

    • 谢谢,我还发现有 ol.proj.toLonLat 但你提出的方法教了更多关于 openlayers-3 的知识!
    • @Sombriks 是的,toLonLat 在这种情况下似乎更合适。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-12
    • 1970-01-01
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多