public static const NUDGE_BACKGROUND:String = "nudge_background";
public static const ERROR:String = "error";
public static const INITIALISED:String = "initialized";
+ public static const BUMP:String = "bump";
public var params:Object;
if (bg.url=='yahoo') { _map.setBackground({url:''}); _yahoo.show(); }
else { _map.setBackground(bg ); _yahoo.hide(); }
// update attribution and logo
- _overlay.visible=bg.attribution || bg.logo;
- setLogo(); setAttribution();
+ _overlay.visible=bg.attribution || bg.logo || bg.terms_url;
+ setLogo(); setAttribution(); setTerms();
// save as SharedObject for next time
var obj:SharedObject = SharedObject.getLocal("user_state");
obj.setProperty('background_url' ,String(bg.url));
setAttribution();
}
private function setAttribution():void {
+ var tf:TextField=TextField(_overlay.getChildAt(0));
+ tf.text='';
if (!selected.attribution) return;
var attr:Array=[];
for (var provider:String in selected.attribution) {
}
}
}
- TextField(_overlay.getChildAt(0)).text="Background "+attr.join(", ");
+ if (attr.length==0) return;
+ tf.text="Background "+attr.join(", ");
+ tf.x=_map.mapwidth - 5 - tf.textWidth;
+ tf.y=_map.mapheight - 5 - tf.textHeight;
+ dispatchEvent(new MapEvent(MapEvent.BUMP, { y: tf.textHeight })); // don't let the toolbox obscure it
}
private function resizeHandler(event:MapEvent):void {
if (!selected.logoData) return;
- _overlay.getChildAt(1).y=event.params.height-5-selected.logoHeight;
+ _overlay.getChildAt(2).y=event.params.height - 5 - selected.logoHeight - (selected.terms_url ? 10 : 0);
}
private function setLogo():void {
+ while (_overlay.numChildren>2) { _overlay.removeChildAt(2); }
if (!selected.logoData) return;
- while (_overlay.numChildren>1) { _overlay.removeChildAt(1); }
var logo:Sprite=new Sprite();
logo.addChild(new Bitmap(selected.logoData));
- logo.x=5; logo.y=_map.mapheight-5-selected.logoHeight;
+ logo.x=5; logo.y=_map.mapheight - 5 - selected.logoHeight - (selected.terms_url ? 10 : 0);
if (selected.logo_url) { logo.buttonMode=true; logo.addEventListener(MouseEvent.CLICK, launchLogoLink, false, 0, true); }
_overlay.addChild(logo);
}
if (!selected.logo_url) return;
navigateToURL(new URLRequest(selected.logo_url), '_blank');
}
+ private function setTerms():void {
+ var terms:TextField=TextField(_overlay.getChildAt(1));
+ if (!selected.terms_url) { terms.text=''; return; }
+ terms.text="Background terms of use";
+ terms.x=5; terms.y=_map.mapheight - 15;
+ terms.addEventListener(MouseEvent.CLICK, launchTermsLink, false, 0, true);
+ }
+ private function launchTermsLink(e:Event):void {
+ if (!selected.terms_url) return;
+ navigateToURL(new URLRequest(selected.terms_url), '_blank');
+ }
[Bindable(event="collection_changed")]
public function getAvailableImagery():ArrayCollection {
// add attribution/logo sprite
var overlay:Sprite=new Sprite();
var attribution:TextField=new TextField();
- attribution.width=200; attribution.height=300;
+ attribution.width=220; attribution.height=300;
attribution.multiline=true;
attribution.wordWrap=true;
attribution.selectable=false;
attribution.defaultTextFormat=new TextFormat("_sans", 9, 0, false, false, false);
- attribution.x=5; attribution.y=5;
overlay.addChild(attribution);
+ var terms:TextField=new TextField();
+ terms.width=200; terms.height=15;
+ terms.selectable=false;
+ terms.defaultTextFormat=new TextFormat("_sans", 9, 0, false, false, true);
+ overlay.addChild(terms);
_root.addChild(overlay);
// mouse-up handler attached to stage, so the user can release outside the map
// initialise imagery and stylesheets
Imagery.instance().init(theMap, overlay, yahoo, loaderInfo.parameters['yahoo_default'] == 'true');
Stylesheets.instance().init(theMap);
+ Imagery.instance().addEventListener(MapEvent.BUMP, bumpHandler);
// keyboard event attached to stage
stage.addEventListener(KeyboardEvent.KEY_UP, theMap.keyUpHandler);
// position toolbox
toolbox=Toolbox(PopUpManager.createPopUp(this,Toolbox,false));
toolbox.init(theController);
- toolbox.x=stage.stageWidth-toolbox.width-15;
- toolbox.y=stage.stageHeight-toolbox.height-15;
+ toolbox.x=stage.stageWidth-toolbox.width-5;
+ toolbox.y=stage.stageHeight-toolbox.height-5;
// add debug field
var t:TextField=new TextField();
theMap.updateSize(map_area.width, map_area.height);
if (toolbox) {
- toolbox.x=Math.min(toolbox.x,stage.stageWidth-toolbox.width-15);
- toolbox.y=Math.min(toolbox.y,stage.stageHeight-toolbox.height-15);
+ toolbox.x=Math.min(toolbox.x,stage.stageWidth-toolbox.width-5);
+ toolbox.y=Math.min(toolbox.y,stage.stageHeight-toolbox.height-5);
}
}
+ private function bumpHandler(e:MapEvent):void {
+ if (toolbox) {
+ toolbox.y=Math.min(toolbox.y,stage.stageHeight-toolbox.height-10-e.params.y);
+ }
+ }
private function onDataStart(event:Event):void {
switch (event.type) {