【问题标题】:how to get the current zoom in openlayers如何在openlayers中获得当前缩放
【发布时间】:2016-08-18 12:05:56
【问题描述】:

我有一个问题。我需要知道开放图层地图的实际缩放比例

$scope.refreshMap = function (lat, long) {
    map.setView(new ol.View({
        projection: 'EPSG:4326',
        center: [long, lat], 
        zoom: "here I do not know what to put"
    }));
};

我尝试使用map.getZoom(),但它不起作用。 logcat 向我抛出了一个

Uncaught TypeError: Object #<S> has no method 'getZoom'

我使用的是 openlayers 版本:v3.16.0

【问题讨论】:

    标签: javascript ionic-framework openlayers-3 angular-openlayers


    【解决方案1】:

    缩放是ol.View 的属性。所以ol.Map 有一个ol.View,它有缩放级别、中心、投影等等。

    map.getView().getZoom();
    

    【讨论】:

      【解决方案2】:
      $scope.refreshMap = function (lat, long) {
                  var actualZoom = map.getView().getZoom();
                  console.log(z);
      
                  map.setView(new ol.View({
                      projection: 'EPSG:4326',
                      center: [long, lat], //long,lat
                      zoom: actualZoom
                  }));
      };
      

      【讨论】:

        猜你喜欢
        • 2019-03-27
        • 2010-11-29
        • 2016-02-09
        • 2015-10-16
        • 2021-05-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多