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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:28:23+00:00 2026-05-31T03:28:23+00:00

I want to add a custom image to my annotations in the map. And

  • 0

I want to add a custom image to my annotations in the map. And i have made the following custom MapAnnotationView:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@class POI;

@interface MapAnnotation : MKAnnotationView <MKAnnotation >

@property (nonatomic) CGFloat lat; 
@property (nonatomic) CGFloat lon;
@property (nonatomic) CGFloat altitude; 
@property (nonatomic,  copy) NSString * title;
@property (nonatomic, copy) NSString * subtitle;
@property (nonatomic,retain) NSString *source;
@property (nonatomic,retain) UIImage  *image;

@end

@implementation MapAnnotation
@synthesize coordinate;
@synthesize lat=_lat,lon=_lon,altitude= _altitude;
@synthesize subtitle= _subtitle, title= _title, source=_source, image =_img;


- (CLLocationCoordinate2D)coordinate;{
    CLLocationCoordinate2D position;
    if (_lat != 0.0 && _lon != 0.0) {
        position.latitude = _lat;
        position.longitude = _lon;

    }else {
        position.latitude=0.0;
        position.longitude=0.0;
    }

    return position; 
}

@end

-(void) mapDataToMapAnnotations{

    NSMutableArray *toRemove = [NSMutableArray arrayWithCapacity:10];
    for (id annotation in _map.annotations)
        if (annotation != _map.userLocation)
            [toRemove addObject:annotation];
    [_map removeAnnotations:toRemove];

    [_data removeAllObjects];

    [_data addObjectsFromArray:[UDdelegate naturArray]];


    if(_data != nil){
        MapAnnotation * tmpPlace;
        //for(NSDictionary * poi in _data){


        for(POI* poi in _data){

            tmpPlace = [[MapAnnotation alloc]init];

            tmpPlace.title = [poi title];
            tmpPlace.lat = [poi lat];
            tmpPlace.lon = [poi lon];
            tmpPlace.subtitle = [poi dist];
            tmpPlace.image = [poi poiIcon];

            [self.map addAnnotation:tmpPlace];
            [_map setNeedsLayout];
        }
    }
}

The problem is that the pins is the standard redPin…. I am sure that the icons isn’t null, have checked for that.

Thanks

  • 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-05-31T03:28:24+00:00Added an answer on May 31, 2026 at 3:28 am

    You have to serve the MapKit delegate method mapView:viewForAnnotation: with a custom view.

    - (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
    {
        static NSString *annotationViewReuseIdentifier = @"annotationViewReuseIdentifier";
    
        MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationViewReuseIdentifier];
    
        if (annotationView == nil)
        {
            annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationViewReuseIdentifier] autorelease];
        }
    
        annotationView.image = [UIImage imageNamed:@"pin_image.png"];
        annotationView.annotation = annotation;
    
        return annotationView;
    }
    

    To encapsulate more you should create a custom annotation view like you did and serve the delegate method above with your class.

    I advise you to rename the MapAnnotation class because it is confusing. There are also Annotations in iOS which are the data holders for those annotation views. To solve this I would prefer to write the type of the inherited class, in this case MKAnnotationView at the end of your custom class. For example CustomPinAnnotationView.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a custom Dialog, but I have problems creating a xml
I have a custom button in outlook and I have to add image icon
I already have a custom UIAlertView and in which i want to add UIImageView
I want to add a background image for some labels in my custom view.
I have a large non-map image that I want to allow people to view
I want add my custom sidebar next right column all page. Please check this
I want to add custom jump list entries to my application in Windows 7.
I want to add custom attribute settings to a generated anchor link of Wordpress.
I am using C#.net I want to add custom edit/delete buttons to my GridView1
I want to add a custom configuration section in my app.config file. Is there

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.