Remember dimming/sharpening preferences
[potlatch2.git] / net / systemeD / halcyon / Map.as
index 973878f..59f93e6 100644 (file)
@@ -12,6 +12,7 @@ package net.systemeD.halcyon {
        import flash.utils.ByteArray;
        import flash.events.*;
        import flash.net.*;
+    import flash.external.ExternalInterface;
 
     import net.systemeD.halcyon.connection.*;
     import net.systemeD.halcyon.connection.EntityEvent;
@@ -115,12 +116,17 @@ package net.systemeD.halcyon {
                // ------------------------------------------------------------------------------------------
                // Initialise map at a given lat/lon
 
-        public function init(startlat:Number,startlon:Number,startscale:uint=0):void {
+        public function init(startlat:Number, startlon:Number, startscale:uint=0):void {
                        while (numChildren) { removeChildAt(0); }
 
                        tileset=new TileSet(this);                                      // 0 - 900913 background
+                       if (initparams['tileblocks']) {                         //   | option to block dodgy tile sources
+                               tileset.blocks=initparams['tileblocks'];//   |
+                       }                                                                                       //   |
                        addChild(tileset);                                                      //   |
-                       tileset.init(tileparams);                                       //   |
+                       tileset.init(tileparams, false, 
+                                    initparams['background_dim']    ==null ? true  : initparams['background_dim'],
+                                    initparams['background_sharpen']==null ? false : initparams['background_sharpen']);
 
                        vectorbg = new Sprite();                                        // 1 - vector background layers
                        addChild(vectorbg);                                                     //   |
@@ -145,7 +151,13 @@ package net.systemeD.halcyon {
                        updateCoords(0,0);
             this.dispatchEvent(new Event(MapEvent.INITIALISED));
                        download();
-                       
+
+            if (ExternalInterface.available) {
+              ExternalInterface.addCallback("setPosition", function (lat:Number,lon:Number,zoom:uint):void {
+                  updateCoordsFromLatLon(lat, lon);
+                  changeScale(zoom);
+              });
+            }
         }
 
                // ------------------------------------------------------------------------------------------
@@ -172,7 +184,7 @@ package net.systemeD.halcyon {
                private function setCentre():void {
                        centre_lat=coord2lat(-y+mapheight/2);
                        centre_lon=coord2lon(-x+mapwidth/2);
-                       this.dispatchEvent(new MapEvent(MapEvent.MOVE, {lat:centre_lat, lon:centre_lon, scale:scale}));
+                       this.dispatchEvent(new MapEvent(MapEvent.MOVE, {lat:centre_lat, lon:centre_lon, scale:scale, minlon:edge_l, maxlon:edge_r, minlat:edge_b, maxlat:edge_t}));
                }
                
                public function nudgeBackground(x:Number,y:Number):void {
@@ -374,6 +386,18 @@ package net.systemeD.halcyon {
                public function setDimming(dim:Boolean):void {
                        if (tileset) { tileset.setDimming(dim); }
                }
+               public function getDimming():Boolean {
+                       if (tileset) { return tileset.getDimming(); }
+                       return true;
+               }
+
+               public function setSharpen(sharpen:Boolean):void {
+                       if (tileset) { tileset.setSharpen(sharpen); }
+               }
+               public function getSharpen():Boolean {
+                       if (tileset) { return tileset.getSharpen(); }
+                       return false;
+               }
 
                // ------------------------------------------------------------------------------------------
                // Export (experimental)