Search code examples
javascriptandroidappcelerator

Can't change annotation image property once is initialized


I create a map module with a custom local image and works fine but later i want to change it for other local image and the image doesnt change on Android, debugging i find the variable "anno.image" does change the value of image with the image i want but doenst render on the map. This is the way im using to create and change the image property. Thanks in advice.

anno.image = "/Imagenes/carrito1.png";

Solution

  • Not sure why it's not rendering the new image but you can remove and re-add this same annotation and it will behave exactly the same way. So basically you can do something like this:

    anno = Map.createAnnotation({
        latitude : anno.latitude,
        longitude : anno.longitude,
        image : "/Imagenes/carrito1.png",
        ..... // copy other properties whatever you had on this anno
    });
    
    MapView.addAnnotations([anno]);