Use the name supplied in the config file for the vector layer
authorAndy Allan <gravitystorm@gmail.com>
Mon, 29 Nov 2010 17:27:46 +0000 (17:27 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Mon, 29 Nov 2010 17:27:46 +0000 (17:27 +0000)
net/systemeD/potlatch2/AutoVectorBackground.as
net/systemeD/potlatch2/utils/BikeShopLoader.as
net/systemeD/potlatch2/utils/BugLoader.as

index 762f950..6a7a92c 100644 (file)
@@ -24,6 +24,7 @@ package net.systemeD.potlatch2 {
         public function onConfigLoad(e:Event):void {
             var xml:XML = XML(e.target.data);
             for each(var set:XML in xml.set) {
+              var name:String = (set.name == undefined) ? null : String(set.name);
               var loader:String = set.loader;
               switch (loader) {
                 case "TrackLoader":
@@ -33,7 +34,8 @@ package net.systemeD.potlatch2 {
 
                 case "BugLoader":
                   if (set.url && set.apiKey) {
-                    var bugLoader:BugLoader = new BugLoader(map, String(set.url), String(set.apikey));
+                    name ||= 'Bugs';
+                    var bugLoader:BugLoader = new BugLoader(map, String(set.url), String(set.apikey), name);
                     if (set.@loaded == "true") {
                       bugLoader.load();
                     }
@@ -44,7 +46,8 @@ package net.systemeD.potlatch2 {
 
                 case "BikeShopLoader":
                   if (set.url) {
-                    var bikeShopLoader:BikeShopLoader = new BikeShopLoader(map, String(set.url));
+                    name ||= 'Missing Bike Shops'
+                    var bikeShopLoader:BikeShopLoader = new BikeShopLoader(map, String(set.url), name);
                     if (set.@loaded == "true") {
                       bikeShopLoader.load();
                     }
index f19f155..71fc118 100644 (file)
@@ -24,12 +24,14 @@ package net.systemeD.potlatch2.utils {
 
         private var map:Map;
         private var bikeShopBaseURL:String;
+        private var name:String;
         private var _layer:VectorLayer;
         private static const STYLESHEET:String="bikeshops.css";
 
-        public function BikeShopLoader(map:Map, url:String) {
+        public function BikeShopLoader(map:Map, url:String, name:String) {
             this.map = map;
             this.bikeShopBaseURL = url;
+            this.name = name;
         }
 
         public function load():void {
@@ -65,12 +67,10 @@ package net.systemeD.potlatch2.utils {
 
         private function get layer():VectorLayer {
             if (!_layer) {
-                var n:String='Bike Shops';
-
                 var policyFile:String = bikeShopBaseURL+"crossdomain.xml";
                 Security.loadPolicyFile(policyFile);
 
-                _layer=new VectorLayer(n,map,STYLESHEET);
+                _layer=new VectorLayer(name,map,STYLESHEET);
                 map.addVectorLayer(_layer);
             }
             return _layer;
index ac4cb1a..17b2b88 100644 (file)
@@ -14,13 +14,15 @@ package net.systemeD.potlatch2.utils {
         private var bugBaseURL:String;
         private var bugApiKey:String;
         private var _layer:VectorLayer;
+        private var name:String;
         private static const STYLESHEET:String="bugs.css";
 
 
-        public function BugLoader(map:Map, url:String, bugApiKey:String):void {
+        public function BugLoader(map:Map, url:String, bugApiKey:String, name:String):void {
             this.map = map;
             this.bugBaseURL = url;
             this.bugApiKey = bugApiKey;
+            this.name = name;
         }
 
         public function load():void {
@@ -30,12 +32,11 @@ package net.systemeD.potlatch2.utils {
 
         private function get layer():VectorLayer {
             if (!_layer) {
-                var n:String='Bugs';
 
                 var policyFile:String = bugBaseURL+"crossdomain.xml";
                 Security.loadPolicyFile(policyFile);
 
-                _layer=new BugLayer(n,map,STYLESHEET,bugBaseURL,bugApiKey);
+                _layer=new BugLayer(name,map,STYLESHEET,bugBaseURL,bugApiKey);
                 map.addVectorLayer(_layer);
             }
             return _layer;