1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 xmlns:halcyon="net.systemeD.halcyon.*"
5 xmlns:potlatch2="net.systemeD.potlatch2.*"
7 horizontalAlign="center"
8 addedToStage="initApp()">
10 <mx:Style source="styles/Application.css"/>
12 <mx:Glow id="glowImage" duration="100"
13 alphaFrom="0.3" alphaTo="1.0"
14 blurXFrom="0.0" blurXTo="5.0"
15 blurYFrom="0.0" blurYTo="5.0"
17 <mx:Glow id="unglowImage" duration="100"
18 alphaFrom="1.0" alphaTo="0.3"
19 blurXFrom="5.0" blurXTo="0.0"
20 blurYFrom="5.0" blurYTo="0.0"
22 <mx:WipeLeft id="wipeOut" duration="250"/>
23 <mx:WipeRight id="wipeIn" duration="250"/>
25 <mx:ApplicationControlBar dock="true">
26 <mx:PopUpButton id="bgButton" label="Background" openAlways="true"
27 creationComplete="bgButton.popUp = new BackgroundSelector();"/>
28 <mx:PopUpButton id="styleButton" label="Map Style" openAlways="true"
29 creationComplete="styleButton.popUp = new StyleSelector();"/>
30 <mx:Spacer width="100%"/>
31 <mx:Button label="Help" click="new HelpDialog().init();" />
32 <mx:Button label="Options" click="new OptionsDialog().init();" />
33 <mx:Button label="Save" icon="@Embed('embedded/save.svg')" click="SaveManager.saveChanges();"/>
34 </mx:ApplicationControlBar>
36 <mx:HDividedBox width="100%" height="100%">
39 <potlatch2:TagViewer width="25%" height="100%" id="tagViewer"/>
41 <mx:Canvas width="75%" height="100%">
42 <mx:Canvas id="map_area" resize="onResizeMap()"
43 top="0" left="0" width="100%" height="100%">
45 <mx:Image source="@Embed('embedded/zoomIn.svg')" right="3" top="3" click="theMap.zoomIn();"
46 rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
47 <mx:Image source="@Embed('embedded/zoomOut.svg')" right="3" top="20" click="theMap.zoomOut();"
48 rollOverEffect="glowImage" rollOutEffect="unglowImage"/>
49 <mx:TextArea id="dataWorking" text="" right="20" top="3" disabledColor="black" backgroundDisabledColor="0xFFFFEA" height="18"
50 enabled="false" borderThickness="0"
51 showEffect="{wipeIn}" hideEffect="{wipeOut}"/>
56 import net.systemeD.halcyon.*;
57 import net.systemeD.halcyon.connection.*;
58 import net.systemeD.potlatch2.*;
59 import net.systemeD.potlatch2.save.SaveManager;
60 import net.systemeD.potlatch2.help.*;
61 import net.systemeD.potlatch2.options.*;
62 import net.systemeD.potlatch2.utils.*;
63 import mx.managers.PopUpManager;
64 import flash.system.Security;
66 import flash.events.MouseEvent;
67 import flash.display.Sprite;
68 import mx.core.IChildList;
69 import mx.containers.Canvas;
70 import mx.core.Application;
71 import com.yahoo.maps.api.YahooMap;
72 import com.yahoo.maps.api.YahooMapEvent;
73 import com.yahoo.maps.api.core.location.LatLon;
75 public var theMap:Map;
76 public var yahooListener:Object = new Object();
77 public var yahoo:YahooMap = new YahooMap();
79 private function initApp():void {
81 Globals.vars.map_area = map_area;
82 Globals.vars.yahoo = yahoo;
83 Globals.vars.root = map_area.rawChildren; // set up global reference to root level
84 var _root:IChildList = map_area.rawChildren; // convenient local shorthand
86 // map backdrop object
87 var w:uint = map_area.width;
88 var h:uint = map_area.height;
89 var b:Sprite = new Sprite();
90 b.height=h; b.width=w;
91 b.graphics.beginFill(0xFFFFEA,100);
92 b.graphics.drawRect(0,0,w,h);
96 // Add Yahoo! background
97 yahoo.init("f0a.sejV34HnhgIbNSmVHmndXFpijgGeun0fSIMG9428hW_ifF3pYKwbV6r9iaXojl1lU_dakekR", w, h);
98 yahoo.mapType="satellite";
99 _root.addChild(yahoo);
104 yahooListener.yahooInit=function(event:YahooMapEvent):void {
105 yahoo.zoomLevel = 18-theMap.scale;
106 yahoo.centerLatLon = new LatLon(theMap.centre_lat, theMap.centre_lon);
108 yahooListener.moveHandler=function(event:MapEvent):void {
109 if (!yahoo.visible) { return; }
110 yahoo.zoomLevel=18-event.params.scale;
111 yahoo.centerLatLon=new LatLon(event.params.lat, event.params.lon);
113 theMap.addEventListener(MapEvent.MOVE, yahooListener.moveHandler);
115 yahooListener.resizeHandler=function(event:MapEvent):void {
116 yahoo.setSize(event.params.width, event.params.height);
118 theMap.addEventListener(MapEvent.RESIZE, yahooListener.resizeHandler);
120 yahoo.addEventListener(YahooMapEvent.MAP_INITIALIZE, yahooListener.yahooInit);
123 theMap=new Map(this.loaderInfo.parameters);
125 _root.addChild(theMap);
126 theMap.updateSize(w, h);
129 var s:Sprite=new Sprite();
130 s.graphics.beginFill(0xFFFFFF,100);
131 s.graphics.drawRect(0,0,w,h);
132 s.graphics.endFill();
138 s.graphics.lineStyle(2,0);
139 s.graphics.moveTo(stage.stageWidth/2-20,stage.stageHeight/2);
140 s.graphics.lineTo(stage.stageWidth/2+20,stage.stageHeight/2);
141 s.graphics.moveTo(stage.stageWidth/2,stage.stageHeight/2-20);
142 s.graphics.lineTo(stage.stageWidth/2,stage.stageHeight/2+20);
145 // mouse-up handler attached to stage, so the user can release outside the map
146 stage.addEventListener(MouseEvent.MOUSE_UP, theMap.mouseUpHandler);
147 Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_MOVE, theMap.mouseMoveHandler);
148 Globals.vars.map_area.addEventListener(MouseEvent.MOUSE_DOWN, theMap.mouseDownHandler);
150 // keyboard event attached to stage
151 stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
153 // example listener event
154 var myListenerObj:Object = new Object();
155 myListenerObj.mapHandler=function(event:MapEvent):void {
156 Globals.vars.debug.appendText("Download event fired - "+event.params.minlat+","+event.params.minlon+"\n");
158 theMap.addEventListener(MapEvent.DOWNLOAD, myListenerObj.mapHandler);
161 var t:TextField=new TextField();
162 t.width=500; t.height=150; t.border=true;
165 Globals.vars.debug=t;
166 t.visible = loaderInfo.parameters["show_debug"] == 'true';
167 Globals.vars.root=theMap; // just for the addDebug function
169 var controller:EditController = new EditController(theMap, tagViewer);
170 controller.setActive();
172 var conn:Connection = Connection.getConnectionInstance();
173 conn.addEventListener(Connection.LOAD_STARTED, onDataStart);
174 conn.addEventListener(Connection.LOAD_COMPLETED, onDataComplete);
176 // and to import a shapefile...
177 // var importer:ShpImporter = new ShpImporter(theMap, ["http://127.0.0.1/~richard/shp/wildrnp020.shp","http://127.0.0.1/~richard/shp/wildrnp020.shx","http://127.0.0.1/~richard/shp/wildrnp020.dbf"]);
180 public function onResizeMap():void {
181 if ( theMap != null )
182 theMap.updateSize(map_area.width, map_area.height);
185 private function onDataStart(event:Event):void {
186 dataWorking.text = event.type == Connection.LOAD_STARTED ? "Loading data..." : "Saving Data...";
187 dataWorking.visible = true;
189 private function onDataComplete(event:Event):void {
190 dataWorking.visible = false;