arcgis API for js 4.X如何获取当前地图的比例尺?

已邀请:
对view添加on事件。
view.on("mouse-wheel", function(event) {
                var num = view.scale;
                console.log(num);
            });
前提:事先在view初始化的时候,添加scale属性,不然获取不到比例尺,

var view = new MapView({
                container: "viewDiv",
                map: map,
                zoom: 4,
                scale: 24000,
                center: [15, 65]
            });
随着鼠标滚轮滑动,比例尺也变动。


QQ截图20201110173311.png

 

知名不具

赞同来自:

view.scale是设置比例尺的啊

朱云峰Yvan

赞同来自:

//显示比列尺,记得提前引用比例尺模块"esri/widgets/ScaleBar",

var scaleBar = new ScaleBar({
view: view,
unit: 'metric' //单位km,默认mile
});
// Add widget to the bottom left corner of the view
view.ui.add(scaleBar, {
position: "bottom-left"
});
 

swaggyP - 网络粉刷匠

赞同来自:

view.scale 就能获取到了

要回复问题请先登录注册