The graduation project uses flex as a map module and ArcGIS API for flex. Today, we will first make a map display and switch, first look at the running effect:
It mainly refers to the use of the dropdownlist control and how to use the ArcGIS control in flex to display maps. Paste the code below:
<? 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" minwidth = "1000" minheight = "600"> <FX: SCRIPT> <! [CDATA [import MX. collections. arraylist; import MX. collections. xmllistcollection; import MX. controls. alert; import MX. events. indexchangedevent; import spark. events. indexchangeevent; private var showmapname: string; Private function mapselectorchangehandler (Event: indexchangeevent): void {showmapname = "http: // service: 8399/ArcGIS/rest/services/" + mapselector. selecteditem. value + "/mapserver/" // alert. show (showmapnam E); mapservicelayer. url = showmapname;}]> </FX: SCRIPT> <FX: declarations> <! -- Place a non-visual element (such as a service or value object) Here --> <s: xmllistcollection id = "mapnames"> <FX: xmllist xmlns = ""> <map> <Name> 856 farms </Name> <value> 856 </value> </map> <Name> ShuangFeng farm </ name> <value> ShuangFeng </value> </map> </FX: xmllist> </S: xmllistcollection> </FX: declarations> <ESRI: map id = "mapview" x = "144" Y = "41" width = "800" Height = "550"> <ESRI: arcgisdynamicmapservicelayer id = "mapservicelayer"/> </ESRI: Map> <s: dropdownlist id = "mapselector" Left = "5" Top = "5" Height = "20" fontsize = "13" fontweight = "normal" dataprovider = "{mapnames}" labelfield = "name" change = "mapselectorchangehandler (Event) "prompt =" map switching "> </S: dropdownlist> </S: Application>
Welcome to the discussion ~~