Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15161] Android: Unable to change the annotation image once the map view is rendered

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionNot Our Bug
Resolution Date2013-09-16T17:18:33.000+0000
Affected Version/sRelease 3.1.1, Release 3.1.2, Release 3.1.3
Fix Version/s2013 Sprint 19, 2013 Sprint 19 API
ComponentsAndroid
LabelssupportTeam
ReporterRupesh Sharma
AssigneeHieu Pham
Created2013-09-13T12:14:52.000+0000
Updated2017-03-29T00:54:30.000+0000

Description

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();

Comments

  1. Hieu Pham 2013-09-16

    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.
  2. Lee Morris 2017-03-29

    Closing ticket as the issue here is not our bug.

JSON Source