762f9509501495530503d5fdd54a6218bf7ca753
[potlatch2.git] / net / systemeD / potlatch2 / AutoVectorBackground.as
1 package net.systemeD.potlatch2 {
2
3     public class AutoVectorBackground {
4
5         import flash.events.*
6         import flash.net.*
7         import net.systemeD.halcyon.Map;
8         import net.systemeD.halcyon.DebugURLRequest;
9         import net.systemeD.potlatch2.utils.*;
10
11         private var map:Map;
12
13         public function AutoVectorBackground(map:Map) {
14             this.map = map;
15         }
16
17         public function load():void {
18             var request:DebugURLRequest = new DebugURLRequest("vectors.xml");
19             var loader:URLLoader = new URLLoader();
20             loader.addEventListener(Event.COMPLETE, onConfigLoad);
21             loader.load(request.request);
22         }
23
24         public function onConfigLoad(e:Event):void {
25             var xml:XML = XML(e.target.data);
26             for each(var set:XML in xml.set) {
27               var loader:String = set.loader;
28               switch (loader) {
29                 case "TrackLoader":
30                   break;
31                 case "KMLImporter":
32                   break;
33
34                 case "BugLoader":
35                   if (set.url && set.apiKey) {
36                     var bugLoader:BugLoader = new BugLoader(map, String(set.url), String(set.apikey));
37                     if (set.@loaded == "true") {
38                       bugLoader.load();
39                     }
40                   } else {
41                     trace("AutoVectorBackground: error with BugLoader");
42                   }
43                   break;
44
45                 case "BikeShopLoader":
46                   if (set.url) {
47                     var bikeShopLoader:BikeShopLoader = new BikeShopLoader(map, String(set.url));
48                     if (set.@loaded == "true") {
49                       bikeShopLoader.load();
50                     }
51                   } else {
52                     trace("AutoVectorBackground: no url for BikeShopLoader");
53                   }
54                   break;
55
56                 default:
57                   trace("AutoVectorBackground: unknown loader");
58               }
59             }
60         }
61     }
62 }