博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
arcgis server javascript api 唯一值渲染
阅读量:5334 次
发布时间:2019-06-15

本文共 3332 字,大约阅读时间需要 11 分钟。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"

   "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>Unique Value Renderer</title>
    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.5/js/dojo/dijit/themes/tundra/tundra.css">
            <script type="text/javascript">var djConfig = {parseOnLoad: true }</script>
    <script type="text/javascript" src= "http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.5"></script>
    <script type="text/javascript" charset="utf-8">
      dojo.require("esri.map");
      dojo.require("esri.tasks.query");
      var map;
      function init() {
        map = new esri.Map("map", {
          extent: new esri.geometry.Extent({xmin:-130.78125,ymin:19.51171875,xmax:-60.46875,ymax:54.66796875,spatialReference:{wkid:4326}}),
          slider: false
        });
        dojo.connect(map, "onLoad", connectErrorHandler);
        dojo.connect(map, "onLoad", doQuery);
        map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"));
      }
      dojo.addOnLoad(init);
      function connectErrorHandler() {
        dojo.connect(map.graphics, "onError", errorHandler);
      }
      function errorHandler(err) {
        console.error(err.message);
      }
      function doQuery() {
        var queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/1");
        var query = new esri.tasks.Query();
        query.where = "1=1";
        query.outFields = ["SUB_REGION"];
        query.returnGeometry = true;
        queryTask.execute(query, addFeatureSetToMap);
      }
      function addFeatureSetToMap(featureSet) {
        //define default symbol for features
        var defaultSymbol = new esri.symbol.SimpleFillSymbol().setStyle(esri.symbol.SimpleFillSymbol.STYLE_NULL);
        defaultSymbol.outline.setStyle(esri.symbol.SimpleLineSymbol.STYLE_NULL);
        //create renderer
        var renderer = new esri.renderer.UniqueValueRenderer(defaultSymbol, "SUB_REGION");
        //add symbol for each possible value
        renderer.addValue("Pacific", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,0,0,0.5])));
        renderer.addValue("Mtn", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0,255,0,0.5])));
        renderer.addValue("N Eng", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0,0,255,0.5])));
        renderer.addValue("S Atl", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,0,255,0.5])));
        renderer.addValue("Mid Atl", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,255,255,0.75])));
        renderer.addValue("E N Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0,255,255,0.5])));
        renderer.addValue("W N Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,255,0,0.5])));
        renderer.addValue("E S Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([127,127,127,0.5])));
        renderer.addValue("W S Cen", new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0,0,0,0.5])));
        map.graphics.setRenderer(renderer);
        dojo.forEach(featureSet.features, function(feature) {
          map.graphics.add(feature);
        });
      }
    </script>
  </head>
  <body>
    <div id="map" class="tundra" style="width:800px; height:400px; border:1px solid #000;"></div>
  </body>
</html>

转载于:https://www.cnblogs.com/longdunxiong/archive/2013/03/21/2973540.html

你可能感兴趣的文章
Vue 2.x + Webpack 3.x + Nodejs 多页面项目框架(上篇——纯前端多页面)
查看>>
display:none与visible:hidden的区别
查看>>
我的PHP学习之路
查看>>
【题解】luogu p2340 奶牛会展
查看>>
对PostgreSQL的 SPI_prepare 的理解。
查看>>
解决响应式布局下兼容性的问题
查看>>
京东静态网页练习记录
查看>>
使用DBCP连接池对连接进行管理
查看>>
【洛谷】【堆+模拟】P2278 操作系统
查看>>
hdu3307 欧拉函数
查看>>
Spring Bean InitializingBean和DisposableBean实例
查看>>
Solr4.8.0源码分析(5)之查询流程分析总述
查看>>
[Windows Server]安装系统显示“缺少计算机所需的介质驱动程序”解决方案
查看>>
[容斥][dp][快速幂] Jzoj P5862 孤独
查看>>
Lucene 学习之二:数值类型的索引和范围查询分析
查看>>
软件开发工作模型
查看>>
Java基础之字符串匹配大全
查看>>
面向对象
查看>>
lintcode83- Single Number II- midium
查看>>
移动端 响应式、自适应、适配 实现方法分析(和其他基础知识拓展)
查看>>