ArcGIS Server JS API开发的一些注意问题

ArcGIS Server JS API开发的一些注意问题。
开发时遇到以下几个问题:
1.打开地图页面时,先将导航工具栏设置为dipslay:none,在地图加载完成以后,再将其设置为display:block,显示地图以后,发现鼠标所指示的经纬度与实际的经纬度,在纬度上相差好几度。具体的值与当前地图的分辨率有关。
2.在显示鹰眼图的页面,当改变鹰眼图所在页面的大小以后,显示的经纬度就会出现问题。

经过查看文档,发现上页面两个问题的原因是:
当更改map所在DIV的位置时,框架不会自动调整map的大小与位置,需要调用map.resize()与map.reposition()这两个函数。

帮助原文如下:

Resizing and repositioning the map
The ArcGIS JavaScript API does not automatically resize the map based on window resizes. You must call Map.resize() whenever the map's container HTML element is resized and the map needs to be adjusted. Similarly, when the map's HTML container has been repositioned in the browser, you need to call Map.reposition().

In Internet Explorer, window.onresize fires a resize event for every pixel that you resize the window. This behavior can slow down your application, especially if your map occupies the full width and height of the browser window or is placed within a container that resizes every time the browser window resizes. The code below contains a timer so that Map.resize() is only called if there is a 500 millisecond delay in the window resize.

var timer;

function init() {
var map = ...;

//connect to window's resize event
dojo.connect(window, "onresize", function() {
//clear any existing resize timer
clearTimeout(timer);
//create new resize timer with delay of 500 milliseconds
timer = setTimeout(function() { map.resize(); }, 500);
});
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值