1. 程式人生 > >gis地圖圖層(前臺)

gis地圖圖層(前臺)

1、dojo框架;

2、包的引用;

3、圖層新增;

<script>
//宣告兩個物件
var myMap;
var mapLayer;
var mapUrl;
dojo.require("esri.config");
dojo.require("dojo/domReady!");
dojo.require("esri.layers.graphics");
dojo.require("esri.layers.GraphicsLayer");
dojo.require("esri.geometry.jsonUtils");
dojo.require("esri.map");//依賴包的引用
dojo.addOnLoad(init);//新增頁面初始化事件 //初始化事件 function init() { //初始化範圍 var initExtent = new esri.geometry.Extent({ "xmin": 12676062, "ymin": 2566164, "xmax": 12710191, "ymax": 2588674, "spatialReference": {"wkid": 102100} }); //定義一個map實體 myMap = new esri.Map("mapDiv", {extent: initExtent});
mapUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"; //定義一個Layer切片圖層 mapLayer = new esri.layers.ArcGISTiledMapServiceLayer(mapUrl); //裝載圖層 myMap.addLayer(mapLayer); //監聽resize方法 dojo.connect(myMap, 'onLoad', function (theMap) { dojo.connect(dijit.byId('mapDiv'),
'resize', myMap, myMap.resize); }); } </script>