ags infoWindow 应用

来源:互联网 发布:网络爬虫视频 编辑:程序博客网 时间:2024/05/18 03:45

1 首先如何设置 infowindow或infoWindowRenderer的边框背景色:

 

Java代码  收藏代码
  1. <fx:Style> @namespace esri "http://www.esri.com/2008/ags";  
  2.         esri|InfoWindowLabel  
  3.         {  
  4.             color: white;  
  5.             font-size: 20;  
  6.         }  
  7.         esri|InfoWindow  
  8.         {  
  9.             border-thickness: 0;  
  10.             background-color: green;  
  11.             font-size: 16;  
  12.             upper-left-radius: 15;  
  13.             upper-right-radius: 0;  
  14.             info-placement: top;  
  15.             info-offset-y: 20;              
  16.         }  
  17.        
  18.     </fx:Style>  

 效果如图:

 

2 点击地图 任意位置 弹出一个信息窗:

Java代码  收藏代码
  1. private function onMouseCLK(event:MapMouseEvent):void  
  2. {  
  3.   myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));  
  4. //设置里面的文字:  
  5. myTextArea.text="asdfasf";  
  6. }  
 

  设置信息泡的组件:

Html代码  收藏代码
  1. <esri:Map id="myMap"   mapClick="onMouseCLK(event)">  
  2.  <esri:infoWindowContent>  
  3.             <mx:TextArea id="myTextArea"  
  4.                          width="250" height="75"/>  
  5.         </esri:infoWindowContent>  
  6. </esri:Map>  
 

3 点击任意一个图元,弹出信息窗:

 方式一: 最简单,直接在给图层的infoWindowRenderer 属性赋值:

Html代码  收藏代码
  1. <esri:GraphicsLayer >   
  2.    <esri:infoWindowRenderer>  
  3.                 <fx:Component>  
  4.                     <mx:VBox backgroundColor="0xffffff"  
  5.                              color="0x444444"  
  6.                              label="Parcel {data.PARCELID}">  
  7.                         <mx:Label text="Owner: {data.OWNERNME1}"/>  
  8.                         <mx:Label text="Address: {data.SITEADDRESS}"/>  
  9.                         <mx:Label text="Land Value: {data.LNDVALUE}"/>  
  10.                         <mx:Label text="Landuse: {data.USECD}"/>  
  11.                     </mx:VBox>  
  12.                 </fx:Component>  
  13.             </esri:infoWindowRenderer>  
  14. <esri:GraphicsLayer/>   
 

 

方式二:  给graphic加 事件,在事件处理函数中弹出信息窗,所以当图元超过500时,效率很差。

<esri:GraphicsLayer id="roadLayer" graphicAdd="fLayer_graphicAddHandler" />

<!--当图层被加入图元时 触发事件-->

 

  protected function fLayer_graphicAddHandler(event:GraphicEvent):void      {                event.graphic.addEventListener(MouseEvent.MOUSE_CLICK, onMouseClkHandler);     }
Js代码  收藏代码
  1. pprivate function onMouseClkHandler(event:MouseEvent):void  
  2.   
  3.               var gr:Graphic = Graphic(event.target);  
  4.               gr.symbol = mouseOverSymbol;  
  5.               myMap.infoWindow.label = gr.attributes.NAME;  
  6.               myMap.infoWindow.closeButtonVisible = false;  
  7.               myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));  
  8.  }  
 

或者:

gra.infoWindowRenderer=new ClassFactory(weatherInfoWin);

gra.symble=....;

0 0