ArcGIS Scalebar 比例尺


說明、這篇博文的示例代碼 地圖充滿body

        arcgis api for javascript iis怎么離線部署 請參考我前面的博文

1、運行效果

3、HTML代碼

<!DOCTYPE html>
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <title>Scalebar應用</title>
   <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js3_api/library/3.3/jsapi/js/dojo/dijit/themes/claro/claro.css"/>
<link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js3_api/library/3.3/jsapi/js/esri/css/esri.css" />

<style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #map{padding:0;}
    </style> 
 
    <script>var dojoConfig = { parseOnLoad: true };</script>

    <script type="text/Javascript" src="http://localhost/arcgis_js3_api/library/3.3/jsapi/init.js"></script>
<script type="text/Javascript">
    var MyMap; var MyTiledMapServiceLayer; dojo.require("dojo.parser"); dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("esri.dijit.Scalebar"); var map; function init() { map = new esri.Map("map", { basemap: "topo", // 指定的地圖底圖.有效選項:"streets","satellite","hybrid","topo","gray","oceans","national-geographic","osm". 
 center: [-116.093, 34.218], zoom: 7 }); dojo.connect(map, "onLoad", function (theMap) { var scalebar = new esri.dijit.Scalebar({ map: map, // 必須的
 scalebarUnit: "english"  // 指定比例尺單位,有效值是"english" or "metric".默認"english"
 }); }); } dojo.ready(init); // 初始化加載
    </script> 
  </head> 
  
  <body class="claro"> 
    <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline', gutters:false" style="width: 100%; height: 100%; margin: 0;"> 
 
      <div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'" style="overflow:hidden;"> 
      </div> 
 
    </div> 
  </body>


</html> 

其中代碼

      map = new esri.Map("map", {
            basemap: "topo", // 指定的地圖底圖.有效選項:"streets","satellite","hybrid","topo","gray","oceans","national-geographic","osm". 
            center: [-116.093, 34.218],
            zoom: 7
        });
也可以替換為下面的形式

map = new esri.Map("map", { center: [-122.445, 37.752], zoom: 4 });
MyTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer
("http://localhost/arcgis/rest/services/DZDT2012/MapServer");
map.addLayer(MyTiledMapServiceLayer);

 

 

注意:直接拷貝代碼的時候 要把引用文件的

 

arcgis_js3_api修改為

 

arcgis_js_api
例如:

 

 <link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js3_api/library/3.3/jsapi/js/dojo/dijit/themes/claro/claro.css"/>修改為

 

<link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_api/library/3.3/jsapi/js/dojo/dijit/themes/claro/claro.css"/>
因為我本機IIS文件夾名稱是

 

arcgis_js3_api

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM