remember background imagery; infinite sublayers; bugfixes
[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.GpxImporter;
13         import net.systemeD.potlatch2.utils.ShpImporter;
14     import mx.managers.PopUpManager;
15     import mx.events.CloseEvent;
16     import mx.core.Application;
17
18     public function init():void {
19         PopUpManager.addPopUp(this, Application(Application.application), true);
20         PopUpManager.centerPopUp(this);
21         this.addEventListener(CloseEvent.CLOSE, vectorDialog_close);
22     }
23     
24     private function vectorDialog_close(evt:CloseEvent):void {
25         PopUpManager.removePopUp(this);
26     }
27
28         private function loadFiles(url:String,filetype:String,simplify:Boolean):void {
29         PopUpManager.removePopUp(this);
30                 var theMap:Map = Globals.vars.root;
31                 var vectorlayer:CustomVectorLayer=new CustomVectorLayer(url,theMap,"potlatch.css");
32                 theMap.vectorlayers.push(vectorlayer);
33                 theMap.vectorbg.addChild(vectorlayer.paint);
34
35                 if (filetype=='gpx') {
36                         var gpx:GpxImporter=new GpxImporter(vectorlayer, vectorlayer.paint, [url], simplify);
37                 } else {
38                         var re:RegExp=/.shp$/i; url=url.replace(re,'');
39                         var shp:ShpImporter=new ShpImporter(vectorlayer,
40                                                             vectorlayer.paint,
41                                                             [url+".shp",url+".shx",url+".dbf"], simplify);
42                 }
43         }
44
45               ]]>
46   </mx:Script>
47   <mx:Text>
48     <mx:text>
49       Input the URL of a file to import.
50     </mx:text>
51   </mx:Text>
52   <mx:TextInput width="100%" id="src" text="" />
53   <mx:RadioButtonGroup id="filetype" />
54   <mx:RadioButton width="100%" groupName="{filetype}" value="shp" id="shp" label="Shapefile" selected="true" />
55   <mx:RadioButton width="100%" groupName="{filetype}" value="gpx" id="gpx" label="GPX" />
56   <mx:CheckBox width="100%" label="Simplify paths" selected="true" id="simplify" />
57   <mx:ControlBar>
58     <mx:Spacer width="100%"/>
59     <mx:Button label="Load" click="loadFiles(src.text, shp.selected?'shp':'gpx', simplify.selected);" enabled="{src.text == '' ? false : true}"/>
60   </mx:ControlBar>
61
62 </mx:TitleWindow>