beginning of vector background layers. And a whole load of other stuff too
[potlatch2.git] / net / systemeD / potlatch2 / VectorSourceDialog.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:TitleWindow
3         xmlns:mx="http://www.adobe.com/2006/mxml" 
4         layout="vertical" showCloseButton="true"
5         horizontalAlign="center" title="Load vector file"
6         width="350" height="250" verticalGap="0">
7   <mx:Script><![CDATA[
8         import net.systemeD.halcyon.Map;
9         import net.systemeD.halcyon.Globals;
10         import net.systemeD.halcyon.vectorlayers.*;
11         import net.systemeD.potlatch2.utils.Importer;
12         import net.systemeD.potlatch2.utils.ShpImporter;
13     import mx.managers.PopUpManager;
14     import mx.events.CloseEvent;
15     import mx.core.Application;
16
17     public function init():void {
18         PopUpManager.addPopUp(this, Application(Application.application), true);
19         PopUpManager.centerPopUp(this);
20         this.addEventListener(CloseEvent.CLOSE, vectorDialog_close);
21     }
22     
23     private function vectorDialog_close(evt:CloseEvent):void {
24         PopUpManager.removePopUp(this);
25     }
26
27         private function loadSHP(url:String):void {
28         PopUpManager.removePopUp(this);
29                 var theMap:Map = Globals.vars.root;
30                 var vectorlayer:CustomVectorLayer=new CustomVectorLayer(theMap,"potlatch.css");
31                 theMap.vectorlayers.push(vectorlayer);
32                 theMap.vectorbg.addChild(vectorlayer.paint);
33
34                 var re:RegExp=/.shp$/i;
35                 url=url.replace(re,'');
36
37                 var shp:ShpImporter=new ShpImporter(vectorlayer,
38                                                     vectorlayer.paint,
39                                                     [url+".shp",url+".shx",url+".dbf"]);
40         }
41
42               ]]>
43   </mx:Script>
44   <mx:Text>
45     <mx:text>
46       Input the URL of a shapefile to import.
47     </mx:text>
48   </mx:Text>
49   <mx:TextInput id="src" text="" />
50   <mx:ControlBar>
51     <mx:Spacer width="100%"/>
52     <mx:Button label="Ok" click="loadSHP(src.text);"/>
53   </mx:ControlBar>
54
55 </mx:TitleWindow>