标签:dex iso arcgis 比例 显示 esri ase 信息 ref
本例展示了如哦读取地图和图层的属性和返回信息给用户。本例中的四个按钮允许用户接收地图属性。每个按钮调用不同的函数。
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> 3 <html> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 6 <meta http-equiv="X-UA-Compatible" content="IE=7" /> 7 8 <title>ArcGIS JavaScript API Map Layer</title> 9 10 <link rel="stylesheet" type="text/css" href="styles.css" 11 href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css"> 12 <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script> 13 <script type="text/javascript"> 14 dojo.require("esri.map"); 15 16 var map,portlandParcels,transportation,census; 17 18 function init(){ 19 map=new esri.Map("map"); 20 //波特兰(美国奥勒冈州最大的城市)地块 21 portlandParcels=new esri.layers.ArcGISDynamicMapServiceLayer( 22 //"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/Portland_ESRI_LandBase_AGO/MapServer" 23 "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer" 24 ); 25 map.addLayer(portlandParcels); 26 //交通系统 27 /* transportation = new esri.layers.ArcGISTiledMapServiceLayer( 28 "http://server.arcgisonline.com/ArcGIS/rest/services/Reference/ESRI_Transportation_World_2D/MapServer", 29 {"id":"agoreference", "opacity":0.5} 30 ); 31 myMap.addLayer(transportation); */ 32 //人口普查 33 /* census = new esri.layers.ArcGISDynamicMapServiceLayer( 34 "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer", 35 {"id":"census","opacity":0.5} 36 ); 37 myMap.addLayer(census); 38 */ 39 40 } 41 //所有图层信息 42 function getMapLayers(){ 43 for(var i=0,i1=map.layerIds.length;i<i1;i++){ 44 var currentlayer=map.getLayer(map.layerIds[i]); 45 alert("id: "+currentlayer.id+",visible:"+currentlayer.visible+",opacity"+currentlayer.opacity); 46 } 47 48 } 49 //控件参考 50 function getSr(){ 51 alert("Spatial Reference WKID:"+map.spatialReference.wkid); 52 53 } 54 //比例级别 55 function getScales(){ 56 var titleInfo=portlandParcels.titleInfo; 57 var scales=""; 58 for(var i=0,j=titleInfo.lods.length;i<j;i++){ 59 var level=titleInfo.lods[i].level; 60 var scale=titleInfo.lods[i].scale; 61 var resolution=titleInfo.lods[i].resolution; 62 scales=scales + "level:" + level + ",scale" + scale + ",resolution" + resolution; 63 } 64 alert(scales); 65 66 } 67 //获取地图宽度和高度 68 69 function getMapWidthHeight(){ 70 alert("Width: " + map.width + "Height: " + map.height); 71 } 72 73 dojo.addOnLoad(init); 74 </script> 75 76 </head> 77 78 <body> 79 <div id="map" class="tundra" style="width:900px;height:600px;border:1px solid #000;"></div> 80 <input type="button" value="所有图层" onclick="getMapLayers()"/> 81 <input type="button" value="控件参考" onclick="getSr()"/> 82 <input type="button" value="比例级别" onclick="getScales()"/> 83 <input type="button" value="地图的宽度高度" onclick="getMapWidthHeight()"/> 84 </body> 85 </html>
ArcGIS api for javascript——显示地图属性
标签:dex iso arcgis 比例 显示 esri ase 信息 ref
原文地址:http://www.cnblogs.com/xiaotian-222/p/6514831.html