Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:14:17+00:00 2026-06-16T17:14:17+00:00

I am getting problem while removing annotations from MKMapView. I have already search for

  • 0

I am getting problem while removing annotations from MKMapView. I have already search for same and found so many answers but couldn’t find satisfactory ans. Below is my code summary:

I have created my custom class as MyMapViewPoints and created one function as

- initWithZTitle:(NSString *)title andCoordinate:(CLLocationCoordinate2D)location

Whenever I want to add annotation I simply create one object of MyMapViewPoints and

[mapView addAnnotation:newAnnotation];

When I want to remove all mapview points (annotations) I execute following code:

for (int i =0; i < [mapView.annotations count]; i++) 
{ 
    if ([[mapView.annotations objectAtIndex:i] isKindOfClass:[MyMapViewPoints class]]) 
    {    
        MyMapViewPoints *obj = (MyMapViewPoints *)[mapView.annotations objectAtIndex:i];
        if(obj.type != 1)
            [mapView removeAnnotation:[mapView.annotations objectAtIndex:i]];
    } 
}

But some of the annotation points remains on map. If I have added six points and tried to remove all using above code 2 mapview points (annotations) retains. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:14:19+00:00Added an answer on June 16, 2026 at 5:14 pm

    just try this code…

    NSArray *existingpoints = mapView.annotations;
    if ([existingpoints count] > 0)
        [mapView removeAnnotations:existingpoints];
    

    UPDATE:

    Also try this code…

    for (int i =0; i < [mapView.annotations count]; i++) { 
        if ([[mapView.annotations objectAtIndex:i] isKindOfClass:[MyMapViewPoints class]]) {                      
             [mapView removeAnnotation:[mapView.annotations objectAtIndex:i]]; 
           } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have problem while getting data from Memcached on .NET MVC solution. I have this
I have a problem while scrolling images on tableview. I am getting a Signal
I am getting invalid identifier problem while requesting for product information I have done
I am getting problem while setting up Session cookie using jersey. is there any
i am getting a problem while populating data inside the dropdown... I guess since
Possible Duplicate: Runtime exception, recursion too deep I'm getting a problem while developing a
as the title says I'm having the problem with content getting hidden while scrolling/dragging
i am getting problem as i have some data in a database tabel file
I have problem while setting the Jlabel location. I set the content pane to
I'm new to Entity Framework and have come across a problem while trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.