Description
If I attempt to set the image of a annotation after it has been added to the map view and that map view has been rendered on screen, you can not change the image of the annotation again.
Although, I have found that if you set the image of an annotation after it has been added to the map view but before that map view has been rendered on screen, then you can change the image of the annotation again.
Test Case
alloy.js
Alloy.Globals.Map = require('ti.map');
index.xml
<Alloy>
<Window>
<View id="mapview" ns="Alloy.Globals.Map" />
</Window>
</Alloy>
index.js
// If the window is opened here then images are not set properly
$.index.open();
// API calls to the map module need to use the Alloy.Globals.Map reference
var mountainView = Alloy.Globals.Map.createAnnotation({
latitude:37.390749,
longitude:-122.081651,
title:"Appcelerator Headquarters"
});
mountainView.setImage('/images/eventMarker.png');
var mountainView2 = Alloy.Globals.Map.createAnnotation({
latitude:37.391749,
longitude:-122.081651,
title:"Appcelerator Headquarters 2"
});
mountainView2.setImage('/images/eventMarker.png');
$.mapview.region = {latitude:37.390749, longitude:-122.081651,
latitudeDelta:0.01, longitudeDelta:0.01};
$.mapview.addAnnotations([mountainView, mountainView2]);
var annotations = $.mapview.getAnnotations();
//Attempt to set the annotation image to something else
for (var i = 0; i < annotations.length; i++) {
annotations[i].setImage('/images/eventMarkerS.png');
alert('Image set to: ' + annotations[i].getImage());
}
// If the window is opened here then images are set properly
// $.index.open();
This is a creation only property, a native Android limitation: https://developers.google.com/maps/documentation/android/marker#add_a_marker (look at 'icon'). Also, this is documented in http://docs.appcelerator.com/titanium/latest/#!/api/Modules.Map.Annotation-property-image. Closing ticket.
Closing ticket as the issue here is not our bug.