PageRenderTime 46ms CodeModel.GetById 37ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/src/com/google/maps/extras/panecontentmanager/AbstractPaneContentManager.as

http://gmaps-utility-library-flash.googlecode.com/
ActionScript | 73 lines | 58 code | 15 blank | 0 comment | 7 complexity | fb46c99c5872c34c8496e7479687fb90 MD5 | raw file
 1package com.google.maps.extras.panecontentmanager
 2{
 3import com.google.maps.MapMouseEvent;
 4import com.google.maps.interfaces.IOverlay;
 5import com.google.maps.interfaces.IPane;
 6
 7import flash.events.EventDispatcher;
 8import flash.events.IEventDispatcher;
 9import flash.utils.Dictionary;
10
11public class AbstractPaneContentManager extends EventDispatcher implements IPaneContentManager
12{
13	public function AbstractPaneContentManager(
14		pane:IPane=null, dataProvider:Array=null,
15		overlayFunction:Function = null)
16	{
17		var target:IEventDispatcher=null;
18		super(target);
19		
20		if(pane != null){
21			this.pane = pane;
22		}
23		
24		if(dataProvider != null){
25			this.dataProvider = dataProvider;
26		}
27		
28		if(overlayFunction != null){
29			this.overlayFunction = overlayFunction;
30		}
31		
32		
33	}
34	
35	protected var thePane:IPane
36	public function set pane(value:IPane):void
37	{
38		this.thePane = value;
39	}
40	
41	private var theDataProvider:Array;
42	public function set dataProvider(value:Array):void
43	{
44		this.theDataProvider = value;
45	}
46	
47	private var theOverlayFunction:Function;
48	public function set overlayFunction(value:Function):void
49	{
50		this.theOverlayFunction = value;
51	}
52	
53	private var _itemToOverlay_dict:Dictionary = new Dictionary;
54	
55	public function execute():void{
56		
57		for each(var item:Object in theDataProvider){
58			var overlay:IOverlay = this.theOverlayFunction(item);
59			overlay.addEventListener(MapMouseEvent.CLICK, onClick_overlay);
60			this.thePane.addOverlay(overlay);
61		}
62	}
63	
64	private function onClick_overlay(event:MapMouseEvent):void{
65		_selectedOverlay = event.target as IOverlay;
66	}
67	
68	private var _selectedOverlay:IOverlay;
69	public function get selectedOverlay():IOverlay{
70		return _selectedOverlay;
71	}
72}
73}