Search code examples
androidappceleratorappcelerator-titaniumappcelerator-studio

Some map annotations with custom images not displayed in Android app


I'm developing an Android app in Appcelerator Studio.

In the app I have a map which displays annotations with different custom images. The annotations are created this way:

annotation = map.createAnnotation({
   image: 'images/pin' + myNumber + '.png',
   latitude: myLat,
   longitude: myLong,
   title: myTitle
});

Almost all of the annotations are displayed, but there are a few which for some reason are invisible. I've verified that 'images/pin' + myNumber + '.png' is the actual path to the image I want to display.

Image which is displayed:

enter image description here

Image which is NOT displayed:

enter image description here

Edit

Things getting weirder.

For testing purpose I created two ImageViews with the image property set to 'images/pin3.png' and 'images/pin163.png' respectively. Both images are displayed. But, as stated, when setting 'images/pin163.png' to an annotation's image property, it is invisble.

I would greatly appreciate your help as I don't have any idea what the issue might be.

Edit 2 with tests:

Nexus 5, Android 6.0.1:

  • Pin 3 is displayed
  • Pin 163 is NOT displayed

Sony Experia Z, Android 4.4:

  • Pin 3 is displayed
  • Pin 163 is NOT displayed

Sony Experia Z, Android 5.Something:

  • Pin 3 is displayed
  • Pin 163 is also displayed

Solution

  • I finally got it working.

    Instead of setting the annotation's image property, I create a view, set the view's backgroundImage property to my image and then assign the view to the annotation's customView property.

    var customAnnotationView = Ti.UI.createView({
        backgroundImage: 'images/pin' + myNumber + '.png',
    });
    
    var annotation = map.createAnnotation({
       customView: customAnnotationView,
       latitude: myLat,
       longitude: myLong,
       title: myTitle
    });