package com.sharewithagent.map
{
    import com.google.maps.LatLng;
    import com.google.maps.overlays.Marker;
    
    import flash.display.Shape;
    import flash.display.Sprite;
    import flash.events.DataEvent;
    import flash.events.MouseEvent;
    import flash.text.*;
    
    import spark.components.Label;

    public class MapMarker extends Sprite
    {
        public var label:Label;
        public var agent:Object;
        public var latlong:LatLng
        public var marker:Marker;
        public var letter:String;
        
        private var arrowBase:Shape;
        private var box:Shape;
        private var islist:Boolean = false;
        
        public function MapMarker(letter:String, isList:Boolean = false)
        {
            super();
            this.letter = letter;
            islist = isList;
            
            var l:TextField = new TextField();
            l.defaultTextFormat = new TextFormat('Arial', 9,0xFFFFFF,true);
            l.text = letter;
            l.mouseEnabled = false;
            l.autoSize = TextFieldAutoSize.LEFT;
            l.width = 28;
            l.height = 20;
            l.y = -20;
            l.x = 2;
            
            arrowBase = new Shape();
            arrowBase.graphics.lineStyle(1,0xFFFFFF);
            arrowBase.graphics.beginFill(0xEA3F23);
            arrowBase.graphics.lineTo(0,-10);
            arrowBase.graphics.lineTo(0,0);
            arrowBase.graphics.lineTo(8,-8);
            arrowBase.graphics.lineStyle(0,0xEA3F23);
            arrowBase.graphics.lineTo(0,-8);
            arrowBase.graphics.lineStyle(1,0xFFFFFF);
            arrowBase.graphics.endFill()
            
            box = new Shape();
            box.graphics.lineStyle(1,0xFFFFFF);
            box.graphics.beginFill(0xea3f23);
            box.graphics.drawRect(0,-20,15,13)
            box.graphics.endFill();
            
            addChild(box);
            addChild(l);
            addChild(arrowBase);
            
            this.mouseChildren = false;
            this.buttonMode = true;
            addEventListener(MouseEvent.CLICK, function(evt:MouseEvent):void {
                dispatchEvent(new DataEvent('button_clicked',true,false,'A'));
            });
            
        }
    }
}