bug annotation
Hello,
I try to add annotations on my mapView, but it doesn't work. Here the simple code : http://pastebin.com/hjFfCaZE Error : "nil argument" ... Ok but what argument?
Do you have any idea how to resolve this?
Thanks!
+1
I know it's an old thread, but I got the same problem. My code:
var Map = require('com.polancomedia.mapbox');
var mapFile = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'custom-world-6.mbtiles');
Ti.App.Map = Map.createView({
map: mapFile,
minZoom: 0,
maxZoom: 6,
zoom: 2,
accessToken: 'xxxxx', //REQUIRED!!!
centerLatLng: [37.322831,7.490234],
width: Ti.UI.FILL,
height: Ti.UI.FILL,
hideAttributes: true,
userLocation: true
});
var a1 = Map.createAnnotation({
latitude: 18.467354,
longitude: -91.903534,
title: "Test Title",
subtitle: "Subtitle"
});
Ti.App.Map.addAnnotation(a1); // Crashes here
With the following error code when adding a annotation:

*** -[__NSCFConstantString stringByAppendingString:]: nil argument
Using Titanium SDK 5.3.1.GA and iOS 9.3
@ilker55 I've come across the same issue.
I used
Ti.App.Map.addAnnotations([a1]);
Although that solved the crash issue for me but I couldn't add any annotations on the map!
Any ways, try it out and tell me if it works.
@Abdelalim-dev When I use addAnnotations I get:
undefined is not a function (evaluating 'Ti.App.Map.addAnnotations([ a1 ])')
And I don't see addAnnotations anywhere in the documentation (https://github.com/adampax/titanium-mapbox/wiki/Annotations).
To be on the same page make sure you are using the same map module I'm using (ti.map). You can check for the latest releases here (https://github.com/appcelerator-modules/ti.map/releases)
To solve the issue of annotations not showing on the map (Android) I used a custom view instead of a simple image like so:
if (OS_IOS) {
annotation.image = image, //your image goes here
annotation.canShowCallout = false;
} else {
annotation.customView = Ti.UI.createLabel({
width : 44,
height : 56,
backgroundImage : image,//your image goes here
});
}
You can then add the annotation to the map.
@Abdelalim-dev To be on the same page make sure you are using the same map module I'm using (ti.map).
But i'm using the map-box module (com.polancomedia.mapbox) so ti.map annotations don't work.