Arcgis js 初学习

每天 我都会改一点 注释也会慢慢加上 希望刚学的一起学习
dojo.require("esri.map");
var map,loading;
function init() {
// var layersLoaded = 0; //varible to keep track of when all layers have been loaded.
loading = dojo.byId("loadingImg"); //loading image. id
map = new esri.Map("map");
dojo.connect(map, "onLoad", showLoading);
dojo.connect(map, "onZoomStart", showLoading);
dojo.connect(map, "onPanStart", showLoading);
var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer");
map.addLayer(tiledMapServiceLayer);
// var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer");
// dynamicMapServiceLayer.setOpacity(0.5);
// map.addLayer(dynamicMapServiceLayer);
// dojo.connect(dynamicMapServiceLayer, "onUpdate", hideLoading);
dojo.connect(tiledMapServiceLayer, "onUpdate", hideLoading);
dojo.connect(map,"onLoad", function(map) {map.infoWindow.resize(250, 100);} );
dojo.connect(map, "onLoad", function() {
//after map loads, connect to listen to mouse move & drag events
dojo.connect(map, "onMouseMove", showCoordinates);
dojo.connect(map, "onMouseDrag", showCoordinates);
});
dojo.connect(map,"onClick",ShowInfo);
}
function showLoading(){
esri.show(loading);
map.disableMapNavigation();//Disallows all map navigation except the slider and pan arrows
map.hideZoomSlider();
}
function hideLoading() {
esri.hide(loading);
map.enableMapNavigation();
map.showZoomSlider();
}
function ShowInfo(evt) {
hideLoading();
var mp = evt.mapPoint;
map.infoWindow.setTitle("坐标");
map.infoWindow.setContent("lat:x "+mp.x+",y "+mp.y+"<br/>+screenx/y"+evt.screenPoint.x+","+evt.screenPoint.y);
map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
}
function showCoordinates(evt) {
//get mapPoint from event
var mp = evt.mapPoint;
//display mouse coordinates
dojo.byId("info").innerHTML = mp.x + ", " + mp.y;

}

dojo.addOnLoad(init);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值