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 8954179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:15:40+00:00 2026-06-15T14:15:40+00:00

i have NSMutableArray that contains multiple places- name,latitude and longitude. those location values are

  • 0

i have NSMutableArray that contains multiple places- name,latitude and longitude. those location values are within the range of 5000 meter from current location. i need to display the annotation pins for those all location in a single map. is it possible?

thanks in advance..

  • 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-15T14:15:41+00:00Added an answer on June 15, 2026 at 2:15 pm
    #import <Foundation/Foundation.h>
    #import <MapKit/MapKit.h>
    
    @interface MyAnnotation : NSObject <MKAnnotation>
    {
    
    CLLocationCoordinate2D  coordinate;
    NSString*               title;
    NSString*               subtitle;
    }
    
    @property (nonatomic, assign)CLLocationCoordinate2D coordinate;
    @property (nonatomic, copy)NSString *title;
    @property (nonatomic, copy)NSString *subtitle;
    
    @end
    
    
    #import "MyAnnotation.h"
    
    @implementation MyAnnotation
    
    @synthesize title;
    @synthesize subtitle;
    @synthesize coordinate;
    
    - (void)dealloc 
    {
        [super dealloc];
        self.title = nil;
        self.subtitle = nil;
    }
    @end
    
    //in your controller in .h
    MyAnnotation* myAnnotation;
    NSMutableArray *annotations;
    
    //im .m file
    - (void)viewDidLoad 
    {
    [super viewDidLoad];
    mapp.showsUserLocation = YES;
    
    mapp.delegate = self;
    
    annotations = [[NSMutableArray alloc] init];
    for (int i=0; i<[arrayLatitude count]; i++)
    {
            CLLocationCoordinate2D theCoordinate1;
    
                theCoordinate1.latitude  = [[arrayLatitude objectAtIndex:i] floatValue];
                theCoordinate1.longitude = [[arrayLongitude objectAtIndex:i] floatValue];
    
                myAnnotation = [[MyAnnotation alloc] init];
                myAnnotation.coordinate = theCoordinate1;
                myAnnotation.title      = [arrayName objectAtIndex:i];
                [mapp addAnnotation:myAnnotation];
                [annotations addObject:myAnnotation]
    
    }
    
    
    NSLog(@"%d",[annotations count]);
    
    
    MKMapRect flyTo = MKMapRectNull;
    for (id <MKAnnotation> annotation in annotations)
    {
        MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
        MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
        if (MKMapRectIsNull(flyTo)) 
        {
            flyTo = pointRect;
        }
        else 
        {
            flyTo = MKMapRectUnion(flyTo, pointRect);
        }
    }
    mapp.visibleMapRect = flyTo;
    
    }
    
    
    - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
    {
    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;
    
    static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
    MKPinAnnotationView* pinView = [[[MKPinAnnotationView alloc]
                                     initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
    pinView.animatesDrop   = NO;
    pinView.canShowCallout = YES;
    pinView.pinColor = MKPinAnnotationColorRed;
    
    UIImageView *icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"%i.jpg",rand()%3908+1]]];
    pinView.leftCalloutAccessoryView = icon;
    [icon release];
    
    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton setTitle:nil forState:UIControlStateNormal];
    [rightButton addTarget:self
                    action:@selector(myMethod:)
          forControlEvents:UIControlEventTouchUpInside];
    pinView.rightCalloutAccessoryView = rightButton;
    
    return pinView;
    }
    
    
    - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
    NSLog(@"Title     : %@",view.annotation.title);
    NSLog(@"Latitude  : %f", view.annotation.coordinate.latitude);
    NSLog(@"Longitude : %f", view.annotation.coordinate.longitude);
    
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSMutableArray that has 5 values initially set to zero. It contains
I have a NSDictionary that contains multiple keys with the same name. Here is
I have a class that contains multiple user objects and as such has an
I have a NSMutableArray that contains all the calendars on my system (as CalCalendar
I have a custom class of type NSObject that contains a single NSMutableArray. This
My NSMutableArray instance contains instances of different types of objects that have common ancestor.
I have an NSMutableArray that contains many NSArrays. At a specific (static) index in
I have a NSMutableArray that contains NSObject. I want to make a copy of
I have a NSDictionary that contains objects and keys. The Keys hold a Name
I have in my App Delegate an NSArray that contains a range of LPProduct

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.