load imagery from XML file
[potlatch2.git] / net / systemeD / potlatch2 / BackgroundSelector.mxml
index 0a28e3b63478d31ca8867bd6854135c44691e61f..1e899a713c8ec4e5f108e15a46ce5ecf95389ae9 100644 (file)
@@ -4,22 +4,8 @@
        paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"
        horizontalAlign="left" backgroundColor="white" borderStyle="inset">
        
-       <mx:List width="100%" height="100%" id="background" change="updateBackground();" verticalScrollPolicy="on"> 
-           <!-- This should be pulled in from an XML file rather than sitting in the source -->
-           <mx:dataProvider>
-               <mx:Object label="None" data="" />
-               <mx:Object label="Yahoo!" data="yahoo" />
-            <mx:Object label="OSM - Mapnik" data="http://tile.openstreetmap.org/$z/$x/$y.png" />
-            <mx:Object label="OSM - Osmarender" data="http://tah.openstreetmap.org/Tiles/tile/$z/$x/$y.png" />
-            <mx:Object label="OSM - Maplint (errors)" data="http://tah.openstreetmap.org/Tiles/maplint/$z/$x/$y.png" />
-            <mx:Object label="OpenCycleMap" data="http://andy.sandbox.cloudmade.com/tiles/cycle/$z/$x/$y.png" />
-                       <mx:Object label="UK: OS StreetView" data="http://os.openstreetmap.org/sv/$z/$x/$y.png" />
-            <mx:Object label="UK historic: 1:25k" data="http://ooc.openstreetmap.org/os1/$z/$x/$y.png" />
-            <mx:Object label="UK historic: 7th" data="http://ooc.openstreetmap.org/os7/$z/$x/$y.png" />
-            <mx:Object label="UK historic: NPE" data="http://ooc.openstreetmap.org/npe/$z/$x/$y.png" />
-            <mx:Object label="Australia: NearMap" data="http://www.nearmap.com/maps/nml=Vert&amp;zxy=$z,$x,$y" />
-           </mx:dataProvider>
-       </mx:List>
+       <mx:List width="100%" height="100%" id="background" change="updateBackground();" verticalScrollPolicy="on" 
+                dataProvider="{_layers}" />
        <mx:CheckBox width="100%" label="Dim background" selected="true" id="dim"
            change="Globals.vars.root.tileset.setDimming(dim.selected); Globals.vars.yahoo.alpha = dim.selected ? 0.5 : 1" />
 
                import net.systemeD.halcyon.connection.*;
                import net.systemeD.potlatch2.*;
                import mx.core.*;
+               import mx.collections.ArrayCollection;
                import mx.managers.PopUpManager;
+               import net.systemeD.halcyon.Globals;
+
+               [Bindable] private var _layers:Array=new Array(
+                       { label: "None", data: "" },
+                       { label: "Yahoo", data: "yahoo" } );
+
+               public function populate(xml:XML):void {
+            for each(var set:XML in xml.set) {
+                _layers.push({ label:set.child("name"), data:set.child("url") });
+            }           
+               }
 
                private function updateBackground():void {
             var theMap:Map = Globals.vars.root;
@@ -43,7 +41,6 @@
                                Globals.vars.yahoo.hide();
                        }
                }
-               
 
     ]]></mx:Script>    
 </mx:VBox>