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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:34:06+00:00 2026-05-26T20:34:06+00:00

My map needs to display RED pins for Venues, and BLUE pins for Parking

  • 0

My map needs to display RED pins for “Venues”, and BLUE pins for “Parking Lots” near and around them.

The problem is that both pins show up in the same color.

The code is below:

My pinAnnotation class looks like this:

#import <MapKit/MapKit.h>


@interface mapPinAnnotation : NSObject  <MKAnnotation>  {    
    NSString *title;
    NSString *subtitle;
    NSString *pinType; // this string will be set to either "Venue" or "Parking"
    CLLocationCoordinate2D coordinate;
}


@property (nonatomic, retain) NSString *title, *subtitle;
@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *pinType;


@end

This is the implementation:

#import "mapPinAnnotation.h"

@implementation mapPinAnnotation

@synthesize coordinate;
@synthesize pinType;
@synthesize title, subtitle;

-(id) initWithCoordinate: (CLLocationCoordinate2D) c {
    coordinate = c;
    return self;
}    

@end

Here is the method setting the pins – note that I use a “tempPin” variable – declared globally – so I can then pass that pin into the “viewForAnnotation” method – but I think this is where the problem is:

-(void) dropThePin {
    CLLocationCoordinate2D location = mapView.userLocation.coordinate;

    location.latitude = latitude;
    location.longitude = longitude;        

    if(pinAnnotation != nil) {
        [mapView removeAnnotation:pinAnnotation];
        [pinAnnotation release];
        pinAnnotation = nil;
    }

    // Create (alloc/init) a Pin, set its Title & Subtitle, and add/place it:
    pinAnnotation = [[mapPinAnnotation alloc] initWithCoordinate:location];
    pinAnnotation.pinType = @"VENUE";

    tempPin = pinAnnotation;

    [pinAnnotation setTitle: @"Some Stadium"];
    [pinAnnotation setSubtitle: @"123 Main St."];

    [mapView addAnnotation:pinAnnotation];


    // Set-Up of 2nd. Pin:
    location.latitude = 12.34567;
    location.longitude = -23.45678;

    pinAnnotation.pinType = @"PARKING";
    if(parkingLotPin != nil) {
        [mapView removeAnnotation:parkingLotPin];
        [parkingLotPin release];
        parkingLotPin = nil;
    }

    // Create (alloc/init) a Pin, set its Title & Subtitle, and add/place it:
    parkingLotPin = [[mapPinAnnotation alloc] initWithCoordinate:location];

    tempPin = pinAnnotation;
    [parkingLotPin setTitle: @"Another Venue"];
    [parkingLotPin setSubtitle: @"789 S. Broad Street"];

    [mapView addAnnotation:parkingLotPin];
    [parkingLotPin release];

}

Finally, here is the “viewForAnnotation” method:

-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation {

    MKPinAnnotationView *thePin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];

    if (tempPin.pinType == @"VENUE") {
        thePin.pinColor = MKPinAnnotationColorGreen;
        NSLog(@"pin-type = %@", tempPin.pinType);
    } else {
        thePin.pinColor = MKPinAnnotationColorPurple;
        NSLog(@"pin-type = %@", tempPin.pinType);
    }

    thePin.animatesDrop=TRUE;
    thePin.canShowCallout = YES;
    thePin.calloutOffset = CGPointMake(-5, 5);
    return thePin;
}

The problem is that both pins show up with the same color.

Any suggestions?

  • 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-26T20:34:07+00:00Added an answer on May 26, 2026 at 8:34 pm

    Try changing:

    if (tempPin.pinType == @"VENUE") {
    

    to:

    if ([((mapPinAnnotation*)annotation).pinType isEqualToString:@"VENUE"]) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that needs to display 30,000 markers on a map
I have a set of points(5-10) that needs to be overlayed on the map.
I would like to display a map on my website that shows my last
I am developing JavaME LWUIT application which needs to display some data on map.
i am developing one application with map view i need display the weather depends
In my QGraphicsView , I display a map. I need to display a horizontal
I've run into a situation where the Table A object needs to map some
I have two methods, the first needs a Map<ItemA, ItemB> the second a Map<ItemA
i´d like to adjust the size of my lines (both of them), because i
I want to make an html5-based webpage for mobile devices that shows a map

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.