Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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?

— asked July 30th 2010 by Pedro Camarelles
  • addannotations
  • android
  • error
  • mapview
  • mobile
0 Comments

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?

    — answered July 30th 2010 by Abraham Vivas
    permalink
    1 Comment
    • Alto si hay metodos de ese tipo (deselectAnnotation y selectAnnotation) voy a probarlos

      — commented August 4th 2010 by Pedro Camarelles
  • 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

    — answered August 4th 2010 by Pedro Camarelles
    permalink
    1 Comment
    • Si te deberia dejar agregarlos. En mi aplicacion si los puedo eliminar y agregar.

      — commented August 4th 2010 by Abraham Vivas
  • 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 :)

    — answered August 4th 2010 by Dan Tamas
    permalink
    1 Comment
    • No problem Tamas, i return to English.
      I have no solution, I also tested the method addAnnotations, selectAnnotation and deselectAnotations.

      Aplication respond me with error "TypeError: Can not call in object property deselectAnnotation titanium.msp.ViewProxy @ 43abf538. it is not a function, it is object"

      On line

      mapa.deselectAnnotation (annotations [i]);
      

      Where mapa is a titanium.map.MapView and anotaciones is an array of titanium.map.Annotation.

      I don't understand?

      There is an inconsistency between the API reference and error, could say that is another youth defect of titanium?

      — commented August 5th 2010 by Pedro Camarelles
  • 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.

    — answered August 5th 2010 by Abraham Vivas
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.