PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/titanium/mobile/map/MapView.hx

http://github.com/visup/haxe-titanium-api
Haxe | 193 lines | 46 code | 8 blank | 139 comment | 0 complexity | 55792a906fef6b55dd86e55bb89b0047 MD5 | raw file
  1package titanium.mobile.map;
  2
  3import titanium.mobile.core.BaseView;
  4import titanium.mobile.core.Dispatcher;
  5
  6/**
  7MapView class
  8
  9Documentation available at:
 10http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.MapView-object.html
 11
 12- namespace
 13
 14Titanium.Map.MapView
 15
 16- type
 17
 18object
 19
 20- subtype
 21
 22view
 23
 24- description
 25
 26The MapView is an object created by [Titanium.Map.createView](Titanium.Map.createView) and is used for embedding native mapping capabilities as a view in your application.  With native maps, you can control the mapping location, the type of map, the zoom level and you can add custom annotations directly to the map.
 27
 28- since
 29
 300.8
 31
 32- platforms
 33
 34android, iphone, ipad
 35
 36- methods
 37
 38zoom: zoom in or out of the map
 39selectAnnotation: cause the annotation to be selected (shown).
 40deselectAnnotation: cause the annotation to be deselected (hidden).
 41addAnnotation: add a new annotation to the map
 42addAnnotations: add one or more new annotation to the map
 43removeAnnotation: remove an existing annotation from the map
 44removeAnnotations: remove one or more existing annotations from the map
 45removeAllAnnotations: removes all annotations added to the map
 46setLocation: set and center the map location.
 47setMapType: set the type of map (satellite, hybrid, standard)
 48
 49# 1.4
 50addRoute: add a route. currently only supported on iphone
 51removeRoute: remove a previously added route. currently only supported on iphone
 52
 53- method : addRoute
 54
 55route[object]: dictionary with the properties: `name` route name, `points` dictionary of values with longitude and latitude keys, `color` for the line color and `width` for the line width.  
 56
 57- method : removeRoute
 58
 59route[object]: same route object used during addRoute
 60
 61- method : addAnnotation
 62
 63annotation[object]: either a dictionary of properties for the annotation or a [Titanium.Map.Annotation](Titanium.Map.Annotation) instance.
 64
 65- method : addAnnotations
 66
 67annotations[array]: an array of either a dictionary of properties for the annotation or a [Titanium.Map.Annotation](Titanium.Map.Annotation) instance.
 68
 69- method : removeAnnotation
 70
 71annotation[string,object]: either a string of the annotation title or a [Titanium.Map.Annotation](Titanium.Map.Annotation) reference.
 72
 73- method : removeAnnotations
 74
 75annotation[array]: an array of either a string of the annotation title or a [Titanium.Map.Annotation](Titanium.Map.Annotation) reference.
 76
 77- method : selectAnnotation
 78
 79annotation[string,object]: either a string of the annotation title or a [Titanium.Map.Annotation](Titanium.Map.Annotation) reference.
 80
 81- method : deselectAnnotation
 82
 83annotation[string,object]: either a string of the annotation title or a [Titanium.Map.Annotation](Titanium.Map.Annotation) reference.
 84
 85- method : zoom
 86
 87level[double]: zoom level (can be positive or negative)
 88
 89- method : setLocation
 90
 91location[object]: a dictionary that specifies the following properties specifying the location to set the map: `latitudeDelta`, `longitudeDelta`, `latitude`, `longitude`.
 92
 93- method : setMapType
 94
 95mapType[int]: the map type constant of either `Titanium.Map.STANDARD_TYPE`, `Titanium.Map.SATELLITE_TYPE` or `Titanium.Map.HYBRID_TYPE`.
 96
 97- properties
 98
 99mapType[int]: the map type constant of either `Titanium.Map.STANDARD_TYPE`, `Titanium.Map.SATELLITE_TYPE` or `Titanium.Map.HYBRID_TYPE`.
100region[object]: a dictionary that specifies the following properties specifying the region location to set the map: `latitudeDelta`, `longitudeDelta`, `latitude`, `longitude`.
101animate[boolean]: boolean is mapping actions should be animated
102regionFit[boolean]: boolean to indicate if the map should attempt to fit the map view into the region in the visible view
103userLocation[boolean]: boolean to indicate if the map should show the user's current device location as a pin on the map
104location[object]: a dictionary that specifies the following properties specifying the region location to set the map: `latitudeDelta`, `longitudeDelta`, `latitude`, `longitude`.
105annotations[array]: an array of annotations to add to the map
106
107- events
108
109regionChanged: fired when the mapping region changes
110loading: fired when the map begins loading
111complete: fired when the map completes loading
112error: fired when the map receives a mapping error
113click: fired when a map view or annotation is touched
114
115- event : regionChanged
116
117latitude: the new latitude
118longitude: the new longitude
119latitudeDelta: the new latitude delta
120longitudeDelta: the new longitude delta
121
122- event : error 
123
124message: the error message
125
126- event : click
127
128clicksource: the source of either `annotation`, `leftButton` or `rightButton` to indicate to location of the click
129annotation: the announce source object
130index: the annotation index
131title: the annotation title
132map: the map view instance
133
134
135- notes
136
137For Android, you will need to <a href="http://code.google.com/android/maps-api-signup.html">obtain a map key from Google</a> to use maps in your application.  On iPhone, you cannot call any methods on a map view until it has been added to a view.
138
139
140**/
141
142typedef MapViewErrorEvent = 
143{ > Event,
144	message:String
145}
146
147typedef MapViewClickEvent = 
148{ > TouchEvent,
149	clicksource:String,
150	annotation:MapAnnotation,
151	index:Int,
152	title:String,
153	map:MapView
154}
155
156@:native("Titanium.Map.MapView")
157extern class MapView extends BaseView
158{
159	// static constructor
160	public inline static function create(?params:Dynamic):MapView
161		return titanium.mobile.Map.createMapView(params)
162		
163	// events
164	public static inline var REGION_CHANGED_EVENT:String = "regionChanged";
165	public static inline var LOADING_EVENT:String = "loading";
166	public static inline var COMPLETE_EVENT:String = "loading";
167	public static inline var ERROR_EVENT:String = "error";
168	public static inline var MAP_CLICK_EVENT:String = "click";
169	
170	// properties
171	public var mapType:Int;
172	public var region:Dynamic;
173	public var regionFit:Bool;
174	public var userLocation:Bool;
175	public var location:Dynamic;
176	public var annotations:Array<MapAnnotation>;
177	
178	// methods
179	public function zoom(level:Float):Void;
180	public function selectAnnotation(annotation:Dynamic):Void;
181	public function deselectAnnotation(annotation:Dynamic):Void;
182	public function addAnnotation(annotation:Dynamic):Void;
183	public function addAnnotations(annotations:Dynamic):Void;
184	public function removeAnnotation(annotation:Dynamic):Void;
185	public function removeAnnotations(annotations:Dynamic):Void;
186	public function removeAllAnnotations():Void;
187	public function setLocation(location:Dynamic):Void;
188	public function setMapType(mapType:Int):Void;
189	#if iphoneos
190	public function addRoute(route:Dynamic):Void;
191	public function removeRoute(route:Dynamic):Void;
192	#end
193}