private function init():void { var xmlLoader:URLLoader = new URLLoader(); xmlLoader.addEventListener(Event.COMPLETE,init_onComplete); xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,test); xmlLoader.load(new URLRequest("parameters.xml")); //this is the configuration file
private function init_onComplete(event:Event):void { var params:Object; var baseImagery:String; var layerBaseImagery:ArcGISTiledMapServiceLayer = new ArcGISTiledMapServiceLayer; try { var loader:URLLoader = URLLoader(event.target); xmlParameters = new XML(loader.data); params = getURLParameters(); if (params["id"]) { input = params.id } else { Alert.show("Parameter search failed"); return; } xmlProjectParameters = xmlParameters.project.(@urlinput==input); var bm:IBrowserManager = BrowserManager.getInstance(); bm.init("", xmlProjectParameters.@id + " BIOMapper"); ///etc. } private function getURLParameters():Object { var result:URLVariables = new URLVariables(); try { if (ExternalInterface.available) { var search:String = ExternalInterface.call("location.search.substring", 1); if (search && search.length > 0) { result.decode(search); } } } catch (error:Error) { Alert.show(error.toString()); } return result; }
baseImagery = xmlProjectParameters.baseimagery; layerBaseImagery.url = serverName + baseImagery + "/MapServer"; mainMap.addLayer(layerBaseImagery);
<?xml version="1.0" encoding="utf-8"?> <projects> <project id="Buck Island" urlinput="BUIS"> <projectname name="Buck Island, USVI" pdftitle="Buck Island, USVI: Shallow-Depth Benthic Habitats" url="http://ccma.nos.noaa.gov/ecosystems/coralreef/stcroix.aspx" projectyear="2011"/> <service>http://egisws02.nos.noaa.gov/ArcGIS/rest/services/biomapper/BUIS_</service> <baseimagery>Imagery</baseimagery>
I'm trying to figure out if it's possible to load map layers in my ArcGIS Flex API flex application via something like a plaintext config file at runtime. Basically, I'm debugging my application in one environment using the public ESRI-provided map layers, and then when I deploy the application, it'll be using an internally-hosted ArcGIS server instance on site. I'd like to be able to let the administrator configure the URIs for the relevant map layers without having to recompile the .swf. Is that doable?Thanks!-Dan
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.