hansemannn / titanium-googlemaps

🗺 Use the Google Maps SDK in Titanium
Other
87 stars 26 forks source link

setAnnotations: Invalid type passed to function/unrecognized selector sent to instance #109

Closed m1ga closed 6 years ago

m1ga commented 6 years ago

Using setAnnotations(array) fails with different error messages using main-thread or not:

var pois = [];
_.each(items, function(item){
    pois.push(Map.createAnnotation({
        latitude: parseFloat(item.lat),
        longitude: parseFloat(item.long),
        title: item.name,
        image: pinImage,
        catid: item.catid,
        subtitle: name,
        id: item.id,
        centerOffset: cOffset
    }));
});

$.mapview.setAnnotations(pois);

with run-on-main-thread=false

[ERROR] Script Error {
[ERROR]     column = 41;
[ERROR]     line = 19;
[ERROR]     message = "Invalid type passed to function";
[ERROR]     nativeLocation = "-[TiGooglemapsViewProxy setAnnotations:] (TiGooglemapsViewProxy.m:378)";
[ERROR]     nativeReason = "expected: Array, was: TiGooglemapsAnnotationProxy";
[ERROR]     stack = "[native code]\n\n";
[ERROR] } 

with run-on-main-thread=true

[ERROR] Script Error {
[ERROR]     column = 41;
[ERROR]     line = 18;
[ERROR]     message = "-[TiGooglemapsAnnotationProxy count]: unrecognized selector sent to instance 0x7f99e5c19d20";
[ERROR]     stack = "[native code]\n\n";
[ERROR] } 

adding them manually with

_.each(pois,function(item){
    $.mapview.addAnnotation(item);
})

works fine and the same setAnnotations() code is working in ti.map (android,ios)

hansemannn commented 6 years ago

Looks like you are passing no array but a single annotation, so it will fail.

hansemannn commented 6 years ago

Closing due to the above reason.