threeve threeve - 3 months ago 23
iOS Question

Appcelerator Titanium Map View - Show Annotation Title By Default

I have a map view:

<View id='map' class='smallMap' module='ti.map' />


I set it up:

$.map.setRegion({
latitude: r.y,
longitude: r.x,
latitudeDelta: 0.1,
longitudeDelta: 0.1
});


I add an annotation:

var annotation = mapModule.createAnnotation({
latitude: x,
longitude: y,
title: location.street,
});
$.map.addAnnotation(annotation);


The latest docs say this:


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.


Is there a way to cause the default state of the annotation to be selected, or to select it without user interaction. Using
annotation.fireEvent('click')
was a bust. Must I overlay a custom view onto the map?

Answer

You can use the selectAnnotation method, example:

$.map.selectAnnotation(annotation);