# Modules.Map.Annotation
Represents a labeled point of interest on the map that the user can click on.
# Overview
The Annotation
object gives you low-level control over annotations that can be added to
Modules.Map.View. An annotation must have its latitude
and longitude
properties set to appear on a map.
Use the Modules.Map.createAnnotation method to create an annotation. Starting with Alloy
1.4.0, use the <Annotation>
Alloy element to define one in XML markup.
An annotation can also have a title, a subtitle, and two inset buttons or views on the left and right side of the title. All of these items are optional.
The controls on the left and right side of the annotation can be specified in one of two ways:
To display an image, set the leftButton or rightButton property to an image URL. (On iOS, you can also use a SystemButton constant to use one of the native system button icons.)
To add another type of view to the annotation, set the leftView or rightView property to a Titanium.UI.View object.
An annotation has two states: selected and deselected. A deselected annotation is marked by a pin image. When the user selects the pin, the full annotation is displayed.
You can specify a custom image for the map pin by setting the Modules.Map.Annotation.image property.
When the user clicks on an annotation, a click
event is generated.
On iOS, You can add a click event listener to a specific annotation, or add a click event listener to the map view to receive click events from all annotations on the map.
On Android, you must add the click event listener to the map view; the annotation itself does not generate these events.
# Properties
# annotationDisplayPriority
The display priority of this annotation view.
An annotation view whose priority is set to MKFeatureDisplayPriorityRequired is always visible on the map, whereas other priorities may result in the annotation view being hidden. Use FEATURE_DISPLAY_PRIORITY_REQUIRED, FEATURE_DISPLAY_PRIORITY_DEFAULT_HIGH or FEATURE_DISPLAY_PRIORITY_DEFAULT_LOW.
Default: Modules.Map.FEATURE_DISPLAY_PRIORITY_REQUIRE
# canShowCallout
Defines whether the annotation view is able to display extra information in a callout bubble.
When this is set to true
, the annotation view shows the callout bubble on selection.
Set this to false
to disabled the showing of the callout bubble on selection.
This must be set before the annotation is added to the map.
If this value is undefined, the value is treated as explicit true.
# centerOffset
Defines a center offset point for the annotation.
By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. Use this property to reposition the annotation view as needed. Positive offset values move the annotation view down and right, while negative values move it up and left.
# clusterIdentifier
An identifier that determines whether the annotation view participates in clustering.
The default value of this property is null, which prevents the annotation view from being clustered with other annotation views. Setting the property to a non null value it to participate in clustering. Clustering occurs when there is a collision between multiple annotation views with the same identifier on the map surface. The annotation views involved in the collision are removed from the map view and replaced by a clustering annotation view, which displays the title from one of the annotations and provides access to the other annotations.
Default: null
# collisionMode
The collision mode to use when interpreting the collision frame rectangle.
# customView
Defines a custom view to be used by the annotation.
Must be set during creation. User interaction is disabled on the view. No view interaction events (click, touchstart etc) will be fired.
# draggable
Determines whether the pin can be dragged by the user.
When an annotation is draggable, it can be moved by the user by long pressing on the pin.
Default: false
# image
Image to use for the the pin.
Must be set during creation. This is ignored if the customView property is set.
Default: If not specified, a standard map pin image is used.
# leftView
Left view that is displayed on the annotation.
This is ignored if the leftButton
property is set.
# markerAnimatesWhenAdded
Boolean indicating whether the marker animates into position onscreen.
Default: false
# markerColor
The background color of the marker balloon.
The default value of this property is undefined, which applies the standard color that is appropriate for the current map style.
# markerGlyphColor
The color to apply to the glyph text or image.
The default value of this property is undefined, which applies the standard tint color for the current map style.
# markerGlyphImage
The image displayed in the marker balloon.
Use this property or the markerGlyphText property to specify the marker balloon content. If you specify both an image and text, the text is displayed. The glyph image is displayed when the marker is in the normal state. Create glyph images as template images so that the glyph tint color can be applied to it. Normally, you set the size of this image to 20 by 20 points on iOS. However, if you do not provide a separate selected image in the markerSelectedGlyphImage property, make the size of this image 40 by 40 points on iOS. MapKit scales images that are larger or smaller than those sizes.
# markerGlyphText
The text to display in the marker balloon.
Use this property or the markerGlyphImage property to specify the marker balloon content. If you specify both an image and text, the text is displayed. The amount of space available for displaying your glyph text is limited. Specify no more than two or three characters for any strings you assign to this property.
# markerSelectedGlyphImage
The image to display when the marker is selected.
The glyph image is displayed when the marker is in the selected state. This image is displayed only when the marker is selected. If you specify an image for this property, you should also specify an image in the markerGlyphImage property. Create glyph images as template images so that the glyph tint color can be applied to it. Set the size of this image to 40 by 40 points on iOS. MapKit scales images that are larger or smaller than those sizes.
# markerSubtitleVisibility
The visibility of the subtitle text rendered below the marker balloon.
The subtitle text is hidden when the marker is not selected. The text is shown when the marker is selected. Use FEATURE_VISIBILITY_ADAPTIVE, FEATURE_VISIBILITY_VISIBLE or FEATURE_VISIBILITY_HIDDEN.
# markerTitleVisibility
The visibility of the title text rendered below the marker balloon.
Title text is normally displayed below the marker balloon. Use FEATURE_VISIBILITY_ADAPTIVE, FEATURE_VISIBILITY_VISIBLE or FEATURE_VISIBILITY_HIDDEN.
# pincolor
The color of the pin-annotation. Use the ANNOTATION_*
constants for pre-
defined colors, e.g ANNOTATION_GREEN
.
Note for iOS: Apps running iOS 9 and later can also specify a non-constant value, e.g. "blue", "rgb(0, 0, 255 ,1)" or "#0000ff".
Pin color is ignored if a custom pin image is specified using image.
# previewContext
The preview context used in the 3D-Touch feature "Peek and Pop".
Preview context to present the "Peek and Pop" of a view. Use an configured instance of Titanium.UI.iOS.PreviewContext here.
Note: This property can only be used on devices running iOS9 or later and supporting 3D-Touch. It is ignored on older devices and can manually be checked using forceTouchSupported.
# rightView
Right view that is displayed on the annotation.
This is ignored if the rightButton
property is set.
# showAsMarker
Boolean to show an annotation view that displays a balloon-shaped marker at the designated location.
Must be set during creation. This is ignored if the customView property is set. See the example "Map Example With Marker Annotation and Clustering".
Default: false
# showInfoWindow
Show or hide the view that is displayed on the annotation when clicked.
When this is false, clicking on the annotation will not center it on the map, but the annotation will still be selected, thus triggering the click event. If the annotation is selected, and the info window is hidden, then the next click will deselect the annotation, thus will NOT show the info window, regardless of the current state of this property.
Default: true
# Methods
# animate
Animate annotation to new location.
Parameters
Name | Type | Description |
---|---|---|
newLocation | Array<Number> | latitude and longitude where annotation will animate. |
Returns
- Type
- void
# rotate
Rotate annotation on its location.
Parameters
Name | Type | Description |
---|---|---|
angle | Number | angle on which annotation will rotate. |
Returns
- Type
- void