/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

  1. package titanium.mobile.map;
  2. import titanium.mobile.core.BaseView;
  3. import titanium.mobile.core.Dispatcher;
  4. /**
  5. MapView class
  6. Documentation available at:
  7. http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Map.MapView-object.html
  8. - namespace
  9. Titanium.Map.MapView
  10. - type
  11. object
  12. - subtype
  13. view
  14. - description
  15. The 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.
  16. - since
  17. 0.8
  18. - platforms
  19. android, iphone, ipad
  20. - methods
  21. zoom: zoom in or out of the map
  22. selectAnnotation: cause the annotation to be selected (shown).
  23. deselectAnnotation: cause the annotation to be deselected (hidden).
  24. addAnnotation: add a new annotation to the map
  25. addAnnotations: add one or more new annotation to the map
  26. removeAnnotation: remove an existing annotation from the map
  27. removeAnnotations: remove one or more existing annotations from the map
  28. removeAllAnnotations: removes all annotations added to the map
  29. setLocation: set and center the map location.
  30. setMapType: set the type of map (satellite, hybrid, standard)
  31. # 1.4
  32. addRoute: add a route. currently only supported on iphone
  33. removeRoute: remove a previously added route. currently only supported on iphone
  34. - method : addRoute
  35. route[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.
  36. - method : removeRoute
  37. route[object]: same route object used during addRoute
  38. - method : addAnnotation
  39. annotation[object]: either a dictionary of properties for the annotation or a [Titanium.Map.Annotation](Titanium.Map.Annotation) instance.
  40. - method : addAnnotations
  41. annotations[array]: an array of either a dictionary of properties for the annotation or a [Titanium.Map.Annotation](Titanium.Map.Annotation) instance.
  42. - method : removeAnnotation
  43. annotation[string,object]: either a string of the annotation title or a [Titanium.Map.Annotation](Titanium.Map.Annotation) reference.
  44. - method : removeAnnotations
  45. annotation[array]: an array of either a string of the annotation title or a [Titanium.Map.Annotation](Titanium.Map.Annotation) reference.
  46. - method : selectAnnotation
  47. annotation[string,object]: either a string of the annotation title or a [Titanium.Map.Annotation](Titanium.Map.Annotation) reference.
  48. - method : deselectAnnotation
  49. annotation[string,object]: either a string of the annotation title or a [Titanium.Map.Annotation](Titanium.Map.Annotation) reference.
  50. - method : zoom
  51. level[double]: zoom level (can be positive or negative)
  52. - method : setLocation
  53. location[object]: a dictionary that specifies the following properties specifying the location to set the map: `latitudeDelta`, `longitudeDelta`, `latitude`, `longitude`.
  54. - method : setMapType
  55. mapType[int]: the map type constant of either `Titanium.Map.STANDARD_TYPE`, `Titanium.Map.SATELLITE_TYPE` or `Titanium.Map.HYBRID_TYPE`.
  56. - properties
  57. mapType[int]: the map type constant of either `Titanium.Map.STANDARD_TYPE`, `Titanium.Map.SATELLITE_TYPE` or `Titanium.Map.HYBRID_TYPE`.
  58. region[object]: a dictionary that specifies the following properties specifying the region location to set the map: `latitudeDelta`, `longitudeDelta`, `latitude`, `longitude`.
  59. animate[boolean]: boolean is mapping actions should be animated
  60. regionFit[boolean]: boolean to indicate if the map should attempt to fit the map view into the region in the visible view
  61. userLocation[boolean]: boolean to indicate if the map should show the user's current device location as a pin on the map
  62. location[object]: a dictionary that specifies the following properties specifying the region location to set the map: `latitudeDelta`, `longitudeDelta`, `latitude`, `longitude`.
  63. annotations[array]: an array of annotations to add to the map
  64. - events
  65. regionChanged: fired when the mapping region changes
  66. loading: fired when the map begins loading
  67. complete: fired when the map completes loading
  68. error: fired when the map receives a mapping error
  69. click: fired when a map view or annotation is touched
  70. - event : regionChanged
  71. latitude: the new latitude
  72. longitude: the new longitude
  73. latitudeDelta: the new latitude delta
  74. longitudeDelta: the new longitude delta
  75. - event : error
  76. message: the error message
  77. - event : click
  78. clicksource: the source of either `annotation`, `leftButton` or `rightButton` to indicate to location of the click
  79. annotation: the announce source object
  80. index: the annotation index
  81. title: the annotation title
  82. map: the map view instance
  83. - notes
  84. For 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.
  85. **/
  86. typedef MapViewErrorEvent =
  87. { > Event,
  88. message:String
  89. }
  90. typedef MapViewClickEvent =
  91. { > TouchEvent,
  92. clicksource:String,
  93. annotation:MapAnnotation,
  94. index:Int,
  95. title:String,
  96. map:MapView
  97. }
  98. @:native("Titanium.Map.MapView")
  99. extern class MapView extends BaseView
  100. {
  101. // static constructor
  102. public inline static function create(?params:Dynamic):MapView
  103. return titanium.mobile.Map.createMapView(params)
  104. // events
  105. public static inline var REGION_CHANGED_EVENT:String = "regionChanged";
  106. public static inline var LOADING_EVENT:String = "loading";
  107. public static inline var COMPLETE_EVENT:String = "loading";
  108. public static inline var ERROR_EVENT:String = "error";
  109. public static inline var MAP_CLICK_EVENT:String = "click";
  110. // properties
  111. public var mapType:Int;
  112. public var region:Dynamic;
  113. public var regionFit:Bool;
  114. public var userLocation:Bool;
  115. public var location:Dynamic;
  116. public var annotations:Array<MapAnnotation>;
  117. // methods
  118. public function zoom(level:Float):Void;
  119. public function selectAnnotation(annotation:Dynamic):Void;
  120. public function deselectAnnotation(annotation:Dynamic):Void;
  121. public function addAnnotation(annotation:Dynamic):Void;
  122. public function addAnnotations(annotations:Dynamic):Void;
  123. public function removeAnnotation(annotation:Dynamic):Void;
  124. public function removeAnnotations(annotations:Dynamic):Void;
  125. public function removeAllAnnotations():Void;
  126. public function setLocation(location:Dynamic):Void;
  127. public function setMapType(mapType:Int):Void;
  128. #if iphoneos
  129. public function addRoute(route:Dynamic):Void;
  130. public function removeRoute(route:Dynamic):Void;
  131. #end
  132. }