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);

你可能感兴趣的:(Arcgis js 初学习)