private var node:Node;
public var map:Map; // reference to parent map
- public var icon:Bitmap; // instance in display list
+ public var icon:Sprite; // instance in display list
public var name:Sprite; // |
private var iconname:String=''; // name of icon
+ public var loaded:Boolean=false;
public static const DEFAULT_TEXTFIELD_PARAMS:Object = {
// embedFonts: true,
// [Embed(source="fonts/DejaVuSans.ttf", fontFamily="DejaVu", fontWeight="normal", mimeType="application/x-font-truetype")]
// public static var DejaVu:Class;
- public function POI(node:Node, map:Map) {
+ public function POI(node:Node, map:Map, sl:StyleList=null) {
this.map = map;
this.node = node;
- redraw();
+ redraw(sl);
}
- public function redraw():void {
+ public function redraw(sl:StyleList=null):Boolean {
var tags:Object = node.getTagsCopy();
// ** apply :hover etc.
- var sl:StyleList=map.ruleset.getStyles(this.node,tags);
+ if (!sl) { sl=map.ruleset.getStyles(this.node,tags); }
+ if (!sl.hasStyles()) { return false; }
+
var r:Boolean=false; // ** rendered
var l:DisplayObject;
for (var sublayer:uint=0; sublayer<10; sublayer++) {
} else {
// already loaded, so just reposition
updatePosition();
- iconname=s.icon_image;
}
}
Sprite(l).removeChild(icon);
iconname='';
}
+ return true;
}
private function loadedIcon(event:Event):void {
- icon = Bitmap(event.target.content);
+ icon = new Sprite();
+ icon.addChild(Bitmap(event.target.content));
var l:DisplayObject=map.getChildAt(map.POISPRITE);
Sprite(l).addChild(icon);
updatePosition();
+
+ icon.addEventListener(MouseEvent.CLICK, mouseEvent);
+ icon.buttonMode = true;
+ icon.mouseEnabled = true;
+
+ loaded=true;
}
+ private function mouseEvent(event:MouseEvent):void {
+ map.entityMouseEvent(event, node);
+ }
+
private function updatePosition():void {
icon.x=map.lon2coord(node.lon)-icon.width/2;
icon.y=map.latp2coord(node.latp)-icon.height/2;
import flash.net.*;
import net.systemeD.halcyon.ImageURLLoader;
- import net.systemeD.halcyon.Globals;
import flash.system.LoaderContext;
public class TileSet extends Sprite {
r=requests.shift(); tz=r[0]; tx=r[1]; ty=r[2];
if (tx>=tile_l && tx<=tile_r && ty>=tile_t && ty<=tile_b) {
// Tile is on-screen, so load
+ waiting++;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, doImgInit);
+ loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, missingTileError);
loader.load(new URLRequest(tileURL(tx,ty)),
new LoaderContext(true));
this.addChild(loader);
}
}
- protected function doImgInit(evt:Event):void {
+ private function missingTileError(event:Event):void {
+ waiting--;
+ return;
+ }
+
+ protected function doImgInit(event:Event):void {
waiting--;
return;
}
}
}
- // ** draw icons
- for (var i:uint = 0; i < way.length; i++) {
- var node:Node = way.getNode(i);
- if (node.hasTags()) {
- map.connection.registerPOI(node);
+ // ** ShieldStyle to do
+ }
+
+ // ** draw icons
+ for (var i:uint = 0; i < way.length; i++) {
+ var node:Node = way.getNode(i);
+ if (map.pois[node.id]) {
+ if (map.pois[node.id].loaded) {
+ map.pois[node.id].redraw();
+ }
+ } else if (node.hasTags()) {
+ sl=map.ruleset.getStyles(node,node.getTagsHash());
+ if (sl.hasStyles()) {
+ map.pois[node.id]=new POI(node,map,sl);
+ // ** this should be done via the registerPOI/event listener mechanism,
+ // but that needs a bit of reworking so we can pass in a styleList
+ // (otherwise we end up computing the styles twice which is expensive)
}
}
-
-
- // ** ShieldStyle to do
}
+
+
// No styles, so add a thin trace
if (!drawn && map.showall) {
return false;
}
+ // ** we could do with hasInterestingTags - don't bother with source, created_by, any TIGER tags, etc.
+
public function getTag(key:String):String {
return tags[key];
}
// data handler
private function loadedImage(event:Event):void {
-Globals.vars.root.addDebug("adding image at "+event.target.filename);
images[event.target.filename]=event.target.data;
iconsToLoad--;
if (iconsToLoad==0 && iconCallback!=null) { iconCallback(); }
import flash.utils.ByteArray;
import flash.net.*;
- import net.systemeD.halcyon.Globals;
public class Style {
public var pointStyles:Array=[];
public var shieldStyles:Array=[];
+ public function hasStyles():Boolean {
+ return ( (shapeStyles.length + textStyles.length + pointStyles.length + shieldStyles.length) > 0 );
+ }
}
}
\ No newline at end of file