zoukankan      html  css  js  c++  java
  • ArcGIS api for javascript——明确的创建图层列表

    描述

    本例展示了如何确切地创建一个地图服务里的图层列表。这个列表由HTML checkboxe组成,可用用于开关图层的可见性。

    函数updateLayerVisibility()包含开关图层的逻辑。函数循环访问列表里的每个图层,依赖checkbox状态图层是否应该可见,并且使用 ArcGISDynamicMapServiceLayer.setVisibleLayers()更新相应图层可见性。

    如果需要创建地图服务里的所有图层的图层列表,见示例动态地创建图层列表.

     1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
     2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//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     <title>明确的创建图层列表</title>
     8     <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css">
     9     <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script>
    10      <script type="text/javascript">
    11         dojo.require("esri.map");
    12         
    13         var dynamicMapServiceLayer,map,visible = [];
    14         
    15         function init() {
    16         
    17             map = new esri.Map("map");
    18             
    19             var imageParameters = new esri.layers.ImageParameters();
    20             imageParameters.visibleLayers = [0,1,2];
    21             
    22             dynamicMapServiceLayer=new esri.layers.ArcGISDynamicMapServiceLayer(
    23             "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer", {"imageParameters":imageParameters}
    24             );
    25             map.addLayer(dynamicMapServiceLayer);
    26         } 
    27     
    28         
    29         function updateLayerVisibility() {      
    30             var inputs = dojo.query(".list_item"), input;
    31             //在这个应用中,图层 2是一只可见的
    32             visible = [2];
    33             for( var i=0,j=inputs.length;i<j;i++) {
    34                 if(inputs[i].checked) {
    35                     visible.push(inputs[i].id);
    36                 }
    37             
    38             }
    39             dynamicMapServiceLayer.setVisibleLayers(visible);
    40                                    
    41         }  
    42         
    43     
    44        dojo.addOnLoad(init);
    45     </script>
    46  
    47   </head>
    48 
    49   <body >
    50   This sample loads an ArcGISDynamicMapServiceLayer and presents check boxes for only the layers that should be toggled on and off by users.  <br />ed to toggle their visibility.<br />
    51     <br />
    52       Layer List: <span id="layer_list"><input type="checkbox" class="list_item" checked="checked" id='0' value=0 onclick="updateLayerVisibility();"/>Cities&nbsp;&nbsp;
    53           <input type="checkbox" class="list_item" checked="checked" id="1" value=1 onclick="updateLayerVisibility();"/>River&nbsp;&nbsp;
    54           
    55       </span><br />
    56       <br />
    57       <div id="map" class="tundra" style=" 900px;height: 600px;border: 1px solid #000"></div>
    58   </body>
    59 </html>
  • 相关阅读:
    Ajax技术应用方面
    关于tomcat环境配置的疑惑(tomcat未进行任何环境配置仍成功显示welcome页面)
    jsp中动态include与静态include的区别
    简单说说tomcat7.0的配置
    传统开发模式与Ajax开发模式的区别
    认识Ajax
    tomcat与jdk的关系
    org.hibernate.TransactionException: nested transactions not supported
    解读Tomcat7.0的startup.bat批处理命令
    forward和redirect的区别
  • 原文地址:https://www.cnblogs.com/xiaotian-222/p/6526025.html
Copyright © 2011-2022 走看看