function OnPageLoad() {
...
map.AttachEvent("oninit", MapInit());
map.Init();
}
function MapInit() {
//在任务栏显示地理坐标
ShowMapCoord();
}
function ShowMapCoord() {
var action = new ShowMapCoordAction();
map.SetAction(action);
}
function ShowMapCoordAction() {
this.type = "SuperMap.IS.MapCoordAction";
this.Init = function(mapControl) {
this.mapControl = mapControl;
if (_ygPos.browser == "ie")
{ mapControl.container.style.cursor = _scriptLocation + "../images/cur_PointQuery.cur"; }
else
{ mapControl.workLayer.style.cursor = "url(images/cur_PointQuery.cur),auto"; };
};
this.Destroy = function() { this.mapControl = null; };
this.OnClick = function(e) { };
this.OnDblClick = function(e) { };
this.OnMouseMove = function(e) { window.status = "当前坐标 X=" + e.mapCoord.x + " Y=" + e.mapCoord.y };
this.OnMouseDown = function(e) { };
this.OnMouseUp = function(e) { };
this.OnContextMenu = function(e) { };
this.GetJSON = function() { return _ActionToJSON(this.type, []); }
}
注意:要想让任务栏一直都能显示出坐标来,包括在放大、缩小的时候,那么需要在放大缩小的OnMouseMove事件中都添加上{ window.status = "当前坐标 X=" + e.mapCoord.x + " Y=" + e.mapCoord.y }