I can add annotations in a mapview with addAnnotations() method
Hello All:
With this code
var mapa = Titanium.Map.createView({
mapType: Titanium.Map.STANDARD_TYPE,
region: posicion,
animate:true,
regionFit:true,
annotations:anotaciones
});
.
.
.
mapa.removeAllAnnotations();
mapa.addAnnotation(anotacion);
.
.
.
mapa.addAnnotations(anotaciones);
In the line mapa.addAnnotations(anotaciones);
i have the error
[TRACE] E/KrollCallback( 922): (kroll$3) [362,42729] ECMA Error evaluating source: TypeError: Cannot call property addAnnotations in object ti.modules.titanium.map.ViewProxy@43b32b60. It is not a function, it is "object".
[TRACE] E/KrollCallback( 922): org.mozilla.javascript.EcmaError: TypeError: Cannot call property addAnnotations in object ti.modules.titanium.map.ViewProxy@43b32b60. It is not a function, it is "object".
I make the test with android emulator APIs 1.6 and Titanium 1.4
Have AddAnnotations a bug? Someone can help me?
4 Answers
-
Pedro,
si al declarar el mapa incluyes
annotations:anotaciones
las anotaciones ya no las tienes que agreagar usando el metodo addAnnotations.Dos cosas, como declaras anotacion, y 2 para que el metodo addAnotations funcione, el variable
anotaciones
tiene que ser un array. Lo es? -
Hola Abraham:
Aunque las anotaciones las cargo al crear el mapa, mas adelante las quito todas y dejo solo una, para posteriormente volverlas a cargar todas, de ahi el removeAllAnnotations.
La creacion de una anotacion
function creaAnotacion(indice, fruteria){ var anotacion = Titanium.Map.createAnnotation({ Id:fruteria.Id, latitude:fruteria.lat, longitude:fruteria.lng, title:'Fruter\xeda', pincolor:Titanium.Map.ANNOTATION_RED, animate:true, datos: fruteria, rightButton:'../images/platano.png', myid:1 }); return anotacion; }
Y la creacion del array anotaciones
for(i=0; i<dimension; i++){ anotaciones[i] = creaAnotacion(i, fruterias[i]); }
Como veras los objetos son los correctos, quizas no me deje volverlos a agregar aunque los haya borrado, como no hay metodos de tipo visible/hidden para las anotaciones, seguire haciendo pruebas.
Un saludo
-
Bueno, español es bonito pero no todo el mundo lo habla, porque no intentamos en ingles? :)
Por si acaso se encuentra la respuesta, los demas no podrian hacer uso de ella…PS. perdonad mi español :)
-
Have you tried creating a new project with the new SDK as default. I have had a couple problems in which for some reason the namespace is not loaded properly and recompiling as a new project does the trick.