Titanium Community Questions & Answer Archive

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

MapView annotation not hiding ?!

Hi,
I have a map with annotations. You can open the annotation and then click on the "rightButton" to slide in a detail view.

mapView.addEventListener('click',function(evt)
{
    // map event properties 
    var annotation = evt.annotation;
    var clickSource = evt.clicksource;
    // Titanium.API.info('MAPVIEW EVENT - click source = '+clickSource+' and offer for '+evt.annotation.offer.city);
    // if (clickSource == 'leftButton' || clickSource == 'title' || clickSource == 'subtitle' || clickSource == 'rightButton')
    if (clickSource == 'rightButton')
    {
        var offer = evt.annotation.offer;
        // not working when clicking left or right button
        mapView.deselectAnnotation(annotation);
        openOfferDetails(offer);
    }
});

My problem is, the annotation is not hidden when I get back from the detail view.

Any idea why?

THX

— asked November 15th 2010 by Czar
  • annotation
  • deselectannotation
  • mapview
0 Comments

3 Answers

  • We are also trying to do almost the exact same thing with zero luck. Anyone made any progress here?

    — answered May 31st 2011 by Gary Williams
    permalink
    0 Comments
  • Hi,

    I try also to hide a part from my annotations. Here is screenshot:
    http://familientagebuch.de/rainer/2011/28.html#2

    In the back page I want to hide/unhide the annotations. They are in an array and are added to the mapview.

    In my function:

    function switchStations(onoff) {
        for (var i=0;i<stations.length;i++) {
            if (onoff=='1') {    
                mapView.selectAnnotation(stations[i]);
            }
            if (onoff=='0') {    
                mapView.deselectAnnotation(mapView.annotations[i]);
                    }
                }
            }
    

    I tried: stations[i] and mapView.annotations[i]. In both cases nothing happens.

    Rainer

    — answered July 12th 2011 by Rainer Schleevoigt
    permalink
    0 Comments
  • Having the same problem here. I created an array of annotations:

    markers[i] = Titanium.Map.createAnnotation({ // etc.
    // etc.
    mapview.addAnnotation(markers[i]);
    

    Then

    for (i = 0; i < markers.length; i++) {
        mapview.deselectAnnotation(markers[i]);
    }
    

    This code does not deselect the annotations, nor does it produce an error. I've printed the object info and verified that markers[i] is in fact an Annotation object.

    RJ

    — answered August 12th 2011 by Richard John
    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.