<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags" pageTitle="FeatureLayer - show InfoWindow on mouseOver"> <!-- This sample shows you how to display an InfoWindow on a mouse over ("map tips"). --> <fx:Script> <![CDATA[ import com.esri.ags.Graphic; import com.esri.ags.SpatialReference; import com.esri.ags.events.GraphicEvent; import com.esri.ags.geometry.Extent; import com.esri.ags.geometry.MapPoint; protected function fLayer_graphicAddHandler(event:GraphicEvent):void { event.graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler); event.graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler); } private function onMouseOverHandler(event:MouseEvent):void { var gr:Graphic = Graphic(event.target); gr.symbol = mouseOverSymbol; myTextArea.htmlText = "<b>2000 Population: </b>" + gr.attributes.POP2000.toString() + "\n" + "<b>2000 Population per Sq. Mi.: </b>" + gr.attributes.POP00_SQMI.toString() + "\n" + "<b>2007 Population: </b>" + gr.attributes.POP2007 + "\n" + "<b>2007 Population per Sq. Mi.: </b>" + gr.attributes.POP07_SQMI; myMap.infoWindow.label = gr.attributes.STATE_NAME; myMap.infoWindow.closeButtonVisible = false; myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY)); } private function onMouseOutHandler(event:MouseEvent):void { var gr:Graphic = Graphic(event.target); gr.symbol = defaultsym; myMap.infoWindow.hide(); } ]]> </fx:Script> <fx:Style> @namespace s "library://ns.adobe.com/flex/spark"; @namespace mx "library://ns.adobe.com/flex/mx"; @namespace esri "http://www.esri.com/2008/ags"; @namespace components "com.esri.ags.components.*"; components|InfoWindow { content-background-alpha : 0; background-color : yellow; background-alpha : 0.8; border-style : solid; } </fx:Style> <fx:Declarations> <esri:SimpleFillSymbol id="mouseOverSymbol" alpha="0.5"> <esri:SimpleLineSymbol width="0" color="0xFF0000"/> </esri:SimpleFillSymbol> <esri:SimpleFillSymbol id="defaultsym" alpha="0.2"> <esri:SimpleLineSymbol width="0" color="0xEEEEEE"/> </esri:SimpleFillSymbol> </fx:Declarations> <s:layout> <s:VerticalLayout/> </s:layout> <esri:Map id="myMap" level="4" load="myMap.centerAt(new MapPoint(-11713000, 4822000))"> <esri:infoWindowContent> <mx:TextArea id="myTextArea" width="250" height="75"/> </esri:infoWindowContent> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> <esri:FeatureLayer id="fLayer" graphicAdd="fLayer_graphicAddHandler(event)" mode="snapshot" outFields="*" symbol="{defaultsym}" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"/> </esri:Map> </s:Application>
<esri:Map id="myMap" load="zoomToUnitedStates()"> <esri:infoWindowContent> <mx:TextArea id="myTextArea" width="250" height="75"/> </esri:infoWindowContent> <esri:FeatureLayer id="fLayer" mode="snapshot" outFields="" graphicAdd="fLayer_graphicAddHandler(event)" url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5"> <esri:renderer> <esri:SimpleRenderer> <esri:symbol> <esri:SimpleFillSymbol id="fillsym" style="solid" color="0x00FF00" alpha="0.6"> <esri:SimpleLineSymbol width="2" color="0x00FF00" alpha="1"/> </esri:SimpleFillSymbol> </esri:symbol> </esri:SimpleRenderer> </esri:renderer> </esri:FeatureLayer> </esri:Map>
import com.esri.ags.events.GraphicEvent; protected function fLayer_graphicAddHandler(event:GraphicEvent):void { // just so we can add tool tips event.graphic.toolTip = event.graphic.attributes.STATE_NAME + "\n"; event.graphic.toolTip += "2007 Population " + event.graphic.attributes.POP2007; }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.