/** * Takes URL for a ArcGIS Server Rest directory and * will attempt to extract the SiteMap. * @param directory */ protected function loadServices(servername:String):void { var service:HTTPService = new HTTPService(); var sitemap:String = "/ArcGIS/rest/services/?f=sitemap"; var url:String = "http://" + servername + sitemap; service.url = url; service.resultFormat = "e4x"; var token:AsyncToken = service.send(); token.addResponder(new AsyncResponder(onServiceResults_handler, onFault_handler)); } /** * Handles the results of accessing the SiteMap. * @param event * @param token */ protected function onServiceResults_handler(event:ResultEvent, token:Object = null):void { var xml:XML = event.result as XML; var xmlColl:XMLListCollection = new XMLListCollection(xml.children()); var list:Array = []; var qn:QName = new QName(sitemapNS, "loc"); var sxml:XML; for each (sxml in xmlColl) { var url:String = sxml[qn].text(); var tmp:Array = url.split("/"); var i:uint = tmp.length; if (tmp[i-1] == "MapServer") { var item:ServiceItem = new ServiceItem(); item.serverType = tmp[i-1]; item.name = tmp[i-2]; item.url = url; list.push(item); findServiceDetails(item); } } list.sortOn("name"); dataList = new ArrayList(list); vUrls = new Vector.<String>(list.length); servicesList.dataProvider = dataList; } /** * Parses <code>ServiceItem</code> object url to find layer details * in service REST. * @param item */ protected function findServiceDetails(item:ServiceItem):void { var jsonurl:String = "?f=json&pretty=false"; var url:String = item.url + jsonurl; var srv:HTTPService = new HTTPService(); srv.url = url; srv.resultFormat = "text"; var token:AsyncToken = srv.send(); token.addResponder(new mx.rpc.Responder(onJSONResult_handler, onFault_handler)); function onJSONResult_handler(event:ResultEvent):void { var data:String = event.result.toString(); // this regex replace can be used to make parsing the JSON faster. // It removes spaces, but it will mess up service description. //data = data.replace( /\s/g, '' ); var details:Object = JSON.decode(data); item.description = details["serviceDescription"]; if (!details["singleFusedMapCache"]) item.type = DYNAMIC; else item.type = TILED; } }
/** * Will find all the items that make up a given map service layer. * @param lyr */ protected function findLayerDetails(lyr:Layer):void { if (layers) layers.removeAll(); layers = new ArrayList(); var layerInfos:Array; layerIDSet = null; layerIDSet = {}; if (lyr is ArcGISDynamicMapServiceLayer) layerInfos = ArcGISDynamicMapServiceLayer(lyr).layerInfos; else if (lyr is ArcGISTiledMapServiceLayer) layerInfos = ArcGISTiledMapServiceLayer(lyr).layerInfos; else if (lyr is FeatureLayer) { var lyrId:int = FeatureLayer(lyr).layerDetails.id; var lyrName:String = FeatureLayer(lyr).layerDetails.name; layerIDSet[lyrName] = lyrId; layers.addItem(lyrName); } if (layerInfos) { var info:LayerInfo; for each (info in layerInfos) { layerIDSet[info.name] = info.id; layers.addItem(info.name); } } }
MadsNice. Works very well. Very configurable as well! To improve the widget it would be nice to have it ignore null values in a table....and also to be able to see the letters you type into the search box. With those two additions it would be absolutely perfect for me!Again - good job!- and perhaps also a clear graphics button...
Hi PhillipThe thing about not seeing what you are typeing into the searchbox, is a problem i don't understand, have you tried my testsite ?? I'll look at the thing about ignore Null values and a clearbutton - thanks for the ideas....Hi Xander - yes the widget is affected by the max. number in the service - and i can see that i have only told about this on the arcgis.com site, not in the info.txt file in the zip-file, sorry - i'll correct this soon - thanks.
Hi,If this widget is affected by the maximum number of records returned by server, what is limitation of the number of records? As I am not seeing all of my results in the drop down. Thanks for any positive reply.
If you follow the directions in the readme file, the autocompletesearch seems to work just fine in 3.0 final.You get a bunch of "no type declaration" warnings in the Flashcommander as component, but it doesn't seem to affect it as it works just fine.R_
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.