From cab97f1df61edb33512a35102ac02653065c155b Mon Sep 17 00:00:00 2001 From: fanzia Date: Mon, 26 Sep 2016 16:32:22 +0800 Subject: [PATCH] =?UTF-8?q?Viewer=E5=A2=9E=E5=8A=A0setMinZoom=E5=92=8CsetM?= =?UTF-8?q?axZoom=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/all/map/map_view_zoom.html | 14 ++++++++++++++ src/GeoBeans/Viewer.js | 28 +++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/example/all/map/map_view_zoom.html b/example/all/map/map_view_zoom.html index 0389f77..9de9088 100644 --- a/example/all/map/map_view_zoom.html +++ b/example/all/map/map_view_zoom.html @@ -142,11 +142,25 @@ alert("当前地图的级别是:" + level); } + + function setMaxZoom(){ + var viewer = mapObj.getViewer(); + + viewer.setMaxZoom(10); + } + + function setMinZoom(){ + var viewer = mapObj.getViewer(); + + viewer.setMinZoom(3); + } Map5 -- 初始化地图 + +
diff --git a/src/GeoBeans/Viewer.js b/src/GeoBeans/Viewer.js index 262714a..b628273 100644 --- a/src/GeoBeans/Viewer.js +++ b/src/GeoBeans/Viewer.js @@ -15,7 +15,8 @@ GeoBeans.Viewer = GeoBeans.Class({ _rotation : 0.0, _resolution : 1.0, - _transformation : null, + _minZoom : null, + _maxZoom : null, initialize : function(map, options){ @@ -526,6 +527,10 @@ GeoBeans.Viewer.prototype.update = function(){ * @return {int} 最大显示级别 */ GeoBeans.Viewer.prototype.getMaxZoom = function(){ + + if(this._maxZoom != null){ + return this._maxZoom; + } var map = this._map; var layers = map.layers; @@ -552,6 +557,9 @@ GeoBeans.Viewer.prototype.getMaxZoom = function(){ * @return {int} 最小显示级别 */ GeoBeans.Viewer.prototype.getMinZoom = function(){ + if(this._minZoom != null){ + return this._minZoom; + } var map = this._map; var layers = map.layers; @@ -572,3 +580,21 @@ GeoBeans.Viewer.prototype.getMinZoom = function(){ } return minZoom; }; + +/** + * 设置最大的显示级别 + * @public + * @param {int} zoom 最大显示级别 + */ +GeoBeans.Viewer.prototype.setMaxZoom = function(zoom){ + this._maxZoom = zoom; +}; + +/** + * 设置最小的显示级别 + * @public + * @param {int} zoom 最小的显示级别 + */ +GeoBeans.Viewer.prototype.setMinZoom = function(zoom){ + this._minZoom = zoom; +} \ No newline at end of file