• ArcGIS Api for js之缩放至图层


    ///----------------------------------------------------------
    //前置条件:地图全局变量的名称为map
    //功能:对行政区划地图中的县城图层
    //      查询当前操作的县城
    //      通过查询,使当前地图视图为该县城的范围,达到缩放至图层的效果
    require(["dojo/parser",
        "dijit/registry",
        'dojo/on',
        "dojo/dom",
        "esri/map",
        "esri/layers/ArcGISDynamicMapServiceLayer",
        "esri/tasks/FindTask",
         "esri/tasks/FindParameters",
        "esri/symbols/SimpleLineSymbol",
        "esri/symbols/SimpleFillSymbol",
        "esri/graphic",
        "dojo/domReady!"],
       function (parser, registry, on, dom, Map, ArcGISDynamicMapServiceLayer, FindTask, FindParameters, SimpleLineSymbol, SimpleFillSymbol) {
           //parser.parse();
           var findTask = new FindTask("http://localhost:6080/arcgis/rest/services/henan/MapServer");
           var FindParameters = new FindParameters();
           var xzFieldName = ["xxx"];//字段名称
           var xzFieldValue = "xxxx";//县名       
           on(dom.byId("BtnSetExtent"), "click", FindByField);
    
           //对字段进行查询
           function FindByField() {
               FindParameters.returnGeometry = true;
               FindParameters.layerIds = [0];
               FindParameters.searchFields = xzFieldName;
               FindParameters.searchText = xzFieldValue;
               findTask.execute(FindParameters, ShowFindResult);
               //alert("3");
           }
           //属性查询结果处理
           function ShowFindResult(queryResult) {
               if (queryResult.length > 0) {
                   var feature = queryResult[0].feature;//[0].feature;
    
                   //创建线符号
                   var lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([54, 141, 58]), 2);
                   //创建面符号
                   var fill = new SimpleFillSymbol(SimpleFillSymbol.STYLE_NULL, lineSymbol);
                   //赋予相应的符号
                   feature.setSymbol(fill);
                   pMap.graphics.clear();
                   pMap.graphics.add(feature);
                   var sGeometry = feature.geometry;
                   var ftGeoExt = sGeometry.getExtent();
                   
                   pMap.setExtent(ftGeoExt);
                   
               }
           }
       });
  • 相关阅读:
    .Net之美读书笔记15
    WinForm跨线程访问控件异常
    .Net之美读书笔记14
    数据库监视器(SQL Server Profilter)
    .Net之美读书笔记13
    .Net之美读书笔记11
    .Net之美读书笔记9
    .Net之美读书笔记8
    tensorflow:验证码的识别(中)
    tensorflow:验证码的识别(上)
  • 原文地址:https://www.cnblogs.com/ciel-shan/p/10951337.html
Copyright © 2020-2023  润新知