在地图上以类似于提示框的方式显示查询信息,类似于arcmap中单击图层查看属性 由于Class Graphic有infoWindowRenderer : IFactory这个属性 (注:infoWindowRenderer property

infoWindowRenderer:IFactory  [read-write] The infoWindowRenderer is a UIComponent factory that is added to a graphic. Wen infoWindowRenderer is defined on a graphic,  a mouse "click" listener is automatically added to the graphic. When graphic is clicked, a UIComponent instance is created,  using the factory and if that factory implements the IDataRenderer interface then its data property is set to the graphic attributes.  In addition, if the UIComponent has a dataProvider property, then that property is set to the graphic attributes as well.  Finally, the map info window content is set to the newly created UIComponent and is shown at an anchor location.  If the geometry of the graphic is a map point, then the anchor location will be that map point, otherwise the anchor point will be where the user clicked map point location.

This property can be used as the source for data binding. 详见:http://resources.esri.com/help/9.3/arcgisserver/apis/flex/apiref/com/esri/ags/Graphic.html#infoWindowRenderer

graphic会自动的监听click事件,当用户单击到图层上的某个元素时,infoWindowRenderer会自动创建一个实例,因此我们只需 private var myInfoWindowRenderer:ClassFactory = new ClassFactory(MyInfoWindowRenderer);

(注:ClassFactory 类实现 IFactory 接口。因此,通过该类,您可以创建可分配到 IFactory 类型属性的对象)

新建Component组建,有两种方式:

1)在mxml内部创建,如下

<mx:Component className="MyInfoWindowRenderer">

<mx:VBox label="{data.STATE_NAME}" backgroundColor="0xEEEEEE">

<mx:Label text="State Fips: {data.STATE_FIPS}"/>

<mx:Label text="Abbreviation: {data.STATE_ABBR}"/>

<mx:Label text="Area: {data.AREA}"/>

</mx:VBox>

</mx:Component>

2)File->New->MXML Component文件,然后在<mx:Script>中导入你新建的as文件(MXML最后会编译成as文件,所以以包的形式导入即可)

例如:import component.MyInfoWindowRenderer;//component是我在当前文件目录下创建的文件夹

第二种方式可降低耦合度(耦合度的强弱可根据系统本身来自行决定,如模块设计科采用高内聚低耦合)

最后便可以进行查询之后的操作啦,例如在click事件里添加一些处理函数等等, 例如(这是自带的一些例子example)

private function onMapClick(event:MapMouseEvent):void

{

query.geometry = event.mapPoint;

queryTask.execute(query);

}

private function onQueryExecuteComplete(event:QueryEvent):void

{

graphicsLayer.clear();

var fset:FeatureSet = event.featureSet;

for each (var graphic:Graphic in fset.features)   //因为每次都选定一个要素,

    {                          //循环遍历只进行一次,因此可以采用下面的方式

     graphic.symbol = symbol;

     graphic.infoWindowRenderer = myInfoWindowRenderer;

    graphicsLayer.add(graphic);   //当然你也可以加载地图的时候便把所有图形要素预加载到

     }                    //graphicsLayer之中,这样提高里查询的效率,但可能会影响加载速度

// fset.features[0].symbol = symbol;

// fset.features[0].infoWindowRenderer = myInfoWindowRenderer;

// graphicsLayer.add(fset.features[0]);

}

infoWindowRenderer之个人见解的更多相关文章

  1. [OC笔记] Category分类之见解

    用过别的语言做过开发的同学都知道,如果你想扩充一个类,就应该去继承这个类.但是OC里面有更好的方法,那就是分类. 那什么是分类呢?就是在不改变原先类,我们可以在其中添加咱们自定义的方法,这样和同事合作 ...

  2. "!x++" 我之见解

    "!x++"之说,各人见解不同,但真理只有一个.我只尝试着说出一种见解,未知真相. 何如? "!x++"等价于"!(x++)". 理论分析 ...

  3. 谈谈自己对于Auth2.0的见解

    Auth的原理网上有很多,我这里就不在赘述了. 这里有张时序图我个人觉得是比较合理而且直观的,(感谢这篇博文:http://justcoding.iteye.com/blog/1950270) 参照这 ...

  4. Qt见解:Post 与 Get 的区别(Get将参数直接与网址整合为一个整体,而Post则将其拆为两个部分)

    第一次接触Qt的Http项目,今天看了一下Post和Get的基本使用方法,就开始尝试了.原先以为Post专门用于向服务器发送请求,然后接收服务器应答的: 而Get只是单纯从服务器获取资源,比如下载这个 ...

  5. IT见解

    IT见解 北京海淀区  2014-10-18   张俊浩 *域名的市值在走低,因其功能被新浪.腾讯微博.微信大V这种账号所代替 *小米将自己定位为互联网公司,而不是手机公司 *手机不远的未来会成为公共 ...

  6. in_array 判断的一些见解

    我个人见解in_array的判断是== 并不是===  证明如下: $arr=(array_merge(range(1, 9),range('a', 'z'),range('A', 'Z')));$m ...

  7. 阿里巴巴Java开发手册———个人追加的见解和补充(一)

    先上干货,<阿里巴巴Java开发手册>的下载地址 https://yq.aliyun.com/articles/69327?spm=5176.100239.blogcont69327.15 ...

  8. React,关于redux的一点小见解

    最近项目做多页面应用使用到了,react + webpack + redux + antd去构建多页面的应用,本地开发用express去模拟服务端程序(个人觉得可以换成dva).所以在这里吐槽一下我自 ...

  9. Qlik报表开发见解

    因为项目需要,最近去做了Qlik Sense报表开发,学习了Qlik报表的开发方法和一些基础的开发模式,以下是我对Qlik报表开发的一些见解,个人水平有限,欢迎大神指导. 1.Qlik Sense的函 ...

随机推荐

  1. RadTextBox允许输入整形数字以及退格键

    勿喷,谢谢!!! //允许输入整形数字以及退格键 using System.Windows.Forms; namespace BaseDataMaintain.Views.Controls{ /// ...

  2. [内核同步]自旋锁spin_lock、spin_lock_irq 和 spin_lock_irqsave 分析

    转自:http://blog.csdn.net/wh_19910525/article/details/11536279 自旋锁的初衷:在短期间内进行轻量级的锁定.一个被争用的自旋锁使得请求它的线程在 ...

  3. 嵌入式设计模式:有限状态自动机的C语言实现

    转自:http://www.cnblogs.com/autosar/archive/2012/06/22/2558604.html 状态机模式是一种行为模式,在<设计模式>这本书中对其有详 ...

  4. C#跟踪和调试程序-Debug类使用

    摘要: 怎样在 Visual C# .NET 中跟踪和调试?当程序运行时,您可以使用 Debug 类的方法来生成消息,以帮助您监视程序执行顺序.检测故障或提供性能度量信息.默认情况下,Debug 类产 ...

  5. eclipse调试总结(转)

    Debug视图 认识debug视图,红色部分框为线程堆栈视图,黄色部分框为表达式.断点.变量视图,蓝色部分为代码视图.  线程堆栈视图 分别介绍一下这几个按钮的含义: 1.表示当前实现继续运行直到下一 ...

  6. MVC 模型

    dbcontent var ALLALBUMS=from album in db.albums orderby album.title ascending select album; storeman ...

  7. OkHttp 源码分析

    在工作中用到封装HTTP传输的OkHTTP,OkHttp是相对成熟的解决方案,同时也是开源项目.本文将从源码角度看下OkHttp是如何实现一些网络操作的. HTTP GET: OkHttpClient ...

  8. 张恭庆编《泛函分析讲义》第二章第4节 $Hahn$-$Banach$ 定理习题解答

    1.次线性泛函的性质 设 $p$ 是实线性空间 $\scrX$ 上的次线性泛函, 求证: (1)$p(0)=0$; (2)$p(-x)\geq -p(x)$; (3)任意给定 $x_0\in \scr ...

  9. Java多线程之捕获异常

    1.主线程不能捕获到子线程的异常 package Thread.Exection; import java.util.concurrent.ExecutorService; import java.u ...

  10. iOS 加入自定义字体方法

    1.网上搜索字体文件(后缀名为.ttf,或.odf) 2.把字体库导入到工程的resouce中 3.在程序添加以下代码 输出所有字体 NSArray *familyNames = [UIFont fa ...