How to get the current scale in openlayers

I have a question. I need to know the actual map scale of the open layers

$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"
    }));
};

I am trying to use map.getZoom(), but it does not work. logcat throws me

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

I am using openlayers Version: v3.16.0

+4
source share
2 answers

Scale is a property ol.View. Thus, it ol.Maphas ol.View, which has a zoom level, center, projection, to say a few.

map.getView().getZoom();
+10
source
$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
            }));
};
0
source

Source: https://habr.com/ru/post/1651666/


All Articles