Removing Annotations

You must Login before you can answer or comment on any questions.

Hi all, i try to get this work, But is not remove the annotations.

mapview.removeAnnotations(cars); not working mapview.addAnnotation(cars); working

b1.addEventListener('click', function()
 {
mapview.removeAnnotations(cars);
b1.hide();
b1on.show(); 
});    
  b1on.addEventListener('click', function()
 {    
mapview.addAnnotation(cars); 
b1on.hide();
b1.show();
});

— asked 8 months ago by Nick Kobo
0 Comments

3 Answers

Is cars an array of annotations or not. You are using addAnnotation <-- singular to add the annotation, but then you are using removeAnnotations <-- plural to remove the same variable.

— answered 8 months ago by Anthony Decena
answer permalink
2 Comments
  • Sorry, cars is array of annotations.

    — commented 8 months ago by Nick Kobo

  • var cars = [car1,car2car3 ext......]; If i use mapview.removeAnnotations(car1,car2,car3,car4 etx.......); is working but if i use mapview.removeAnnotations(cars); is not working..

    — commented 8 months ago by Nick Kobo

Assuming cars is a single annotation object, try either: mapview.removeAnnotation(cars); or mapview.removeAnnotations([cars]);

— answered 8 months ago by Adam Paxton
answer permalink
3 Comments
  • Car is array of annotations. var cars = [car1,car2car3 ext......]; If i use mapview.removeAnnotations(car1,car2,car3,car4 etx.......); is working but i use mapview.removeAnnotations(cars); is not working..

    — commented 8 months ago by Nick Kobo

  • What platform and version are you running on? Also, what Titantium SDK

    — commented 8 months ago by Adam Paxton

  • iPhone. Ihave try with several SDKs 2.1.3, .2.1.2, 1.8, 3,1

    — commented 8 months ago by Nick Kobo

I have the same issue using Titanium 3.0 beta running on the iPad emulator (iOS 6.0). I get the desired result if I call mapview.removeAnnotations.apply(mapview, annotations) (where annotations is an array).

The documentation indicates that mapview.removeAnnotations is unavailable on Android, however. I wonder if fixing this bug would make it work on Android.

Your Answer

Think you can help? Login to answer this question!