zoukankan      html  css  js  c++  java
  • arcgis api for flex 开发入门(六)identify<转>

    arcgis api for flex 开发入门(六)identify
    identify 是GIS中比较常用的工具之一,在arcgis api for flex中esri为我们提
    供了一个Identify Task来轻松完成identify 的功能。
    首先,还是使用<esri:IdentifyTask>标签来创建一个Identify Task。
        <!-- Identify Task -->
        <esri:IdentifyTask id="identifyTask"
            identifyComplete="identifyCompleteHandler(event)"        
    url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Special
    ty/ESRI_StatesCitiesRivers_USA/MapServer"/>
    当identifyTask执行完毕的时候响应identifyComplete消息,我们就可以把
    identify的结果做一些处理,比如添加到Graphic layer 上。
    在执行identify之前,首先要对identify的参数设置一下,我们需要一个
    IdentifyParameters对象。下面的代码是AS3脚本的代码,用来创建
    IdentifyParameters和identify执行。
      var identifyParams : IdentifyParameters = new IdentifyParameters();
                    identifyParams.returnGeometry = true;
                    identifyParams.tolerance = 3;
                    identifyParams.width = 600;
                    identifyParams.height = 550;
                    identifyParams.geometry = geometry;
      identifyParams.layerOption =
    IdentifyParameters.LAYER_OPTION_ALL;
                    identifyParams.mapExtent = map.extent;                  
                    identifyTask.execute( identifyParams );
    其中tolerance是容差半径
    Width of the map currently being viewed in pixels.
    height : Height of the map currently being viewed in pixels
    geometry 是用来做identify的几何,常用的有点选,矩形选择,多边形选择等
    参数设置好了之后,直接调用identifyTask.execute( identifyParams );就ok了

    那么我们用来做identify的几何怎么来呢,在什么时候去做Identify呢?
    首先回答第一个问题,做identify的几何我们可以利用第四讲中draw控件使用鼠
    标交互来获得,这也是RIA的特点之一。
    那么在什么时候做identify呢?
    就在做identify的几何画完之后做,嘿嘿,等于没说嘛,当然要在画完了就做:-D
    现在我们就来完成上面的工作
    定义一个draw控件
    <esriraw id="drawToolbar" map="{map}"
    graphicsLayer="{myGraphicsLayer}" drawEnd="drawEndHandler(event)">
    记得添加上drawEnd消息的响应函数drawEndHandler(event),这个事件会在draw
    之后响应。
    用as3脚本实现drawEndHandler和identifyCompleteHandler函数
    private function drawEndHandler(eventrawEvent):void
                {
                    var geometry : Geometry = event.geometry;
                    var identifyParams : IdentifyParameters = new
    IdentifyParameters();
                    identifyParams.returnGeometry = true;
                    identifyParams.tolerance = 3;
                    identifyParams.width = 600;
                    identifyParams.height = 550;
                    identifyParams.geometry = geometry;
      identifyParams.layerOption =
    IdentifyParameters.LAYER_OPTION_ALL;
                    identifyParams.mapExtent = map.extent;                  
                    identifyTask.execute( identifyParams );
               
               private function identifyCompleteHandler
    (event:IdentifyEvent):void
               {
                   for each (var result:IdentifyResult in
    event.identifyResults)
                   {
                       myGraphicsLayer.add(result.feature);
                   }
               }
    Code
    原文地址:http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=35661&extra=page%3D4%26amp%3Borderby%3Ddateline
  • 相关阅读:
    IPC之PIPE
    MSChart的研究(转)
    计算机信息类ComputerInfo(车)
    c# 操作Word总结(车)
    js跳转页面(转)
    textarea中的回车识别问题
    js的页面传值cookie.session
    destoon使用
    vscode 配置php
    vscode开发c#
  • 原文地址:https://www.cnblogs.com/wenjl520/p/1494570.html
Copyright © 2011-2022 走看看