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);
});
}
开发时遇到以下几个问题:
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);
});
}