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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:37:32+00:00 2026-06-02T18:37:32+00:00

I currently have a map view that is populated with several objects following the

  • 0

I currently have a map view that is populated with several objects following the MKAnnotation protocol. There is two separate types of objects, stores and competitors. The different objects have different types of data attached to them.

When the mapView is loaded, the program automatically drops all the pins for our stores and competitors onto the map. Each pin uses a custom image. When you zoom out to a larger area, obviously the screen can get quite cluttered. I have looked at filtering objects based on proximity as described in this blog: http://www.fiveminutes.eu/having-fun-with-ios-map-kit-grouping-annotations/

But after discussing it with some coworkers, we decided to try instead to switch our fairly large “square-styled” pins with smaller needle-point pins after the map region was changed to have a latitude or longitude delta greater than 1.0

I have created the methods and implemented the process to achieve switching between the smaller and larger pins as a user zooms in and out, but I cannot seem to get rid of this warning:

Sending "MKAnnotationView *" to parameter of incompatible type 'id<MKAnnotation>'

I know that this means we are probably doing something wrong which could in the future cause problems, so I would like to get it fixed before our v1.1 release in a few days.

The following method is how I test to see if my region has changed beyond the point where I want to change pins. usingLargeIcons is a Boolean value that just keeps keeps us from calling the change method when the icons are already at the desired size.

-(void)mapView:(MKMapView *)mapViewChanged regionDidChangeAnimated:(BOOL)animated
{
    NSLog(@"latitudeDelta = %f",mapViewChanged.region.span.latitudeDelta);
    NSLog(@"longitudeDelta = %f",mapViewChanged.region.span.longitudeDelta);
    //Sanity check on region
    if(mapView.region.span.latitudeDelta < 1.0){
        if(!usingLargeIcons){
            [self transformPinsLarge];
        }
    }else{
        if(usingLargeIcons){
            [self transformPinsSmall];
        }
    }
}

This method as you can see is just calling two transform methods. The methods are almost identical, but have two simple word changes Small and Large. My goal was to take all the pins on the map and dump them into an array, cycle through the array and switch to the smaller pins. I don’t understand why we are receiving the warning about our objects not matching up. If I have missed this on another questions here at SO, I apologize, please just point me in the right direction and I’ll be on my way. I have Google searched several style questions and haven’t found anything to describe this object warning.

The transform methods:

- (void)transformPinsSmall
{
    usingLargeIcons = NO;
    NSArray *allPins = [mapView annotations];
    for (MKAnnotationView *a in allPins) {
        //Gets small UIImage for brand, changes pin image
        [[mapView viewForAnnotation:a] setImage:[self imageForSmallAnnotation:a]];
    }
}

The warning is on the line of code in the for loop. The “imageForSmallAnnotation” method is just returning a UIImage object. Can someone please explain to me how to type cast these images or how to cast my method declaration so that I can remove these errors?

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-06-02T18:37:33+00:00Added an answer on June 2, 2026 at 6:37 pm

    Any chance the error message is actually

    Sending "MKAnnotationView *" to parameter of incompatible type 'id<MKAnnotation>'
    

    …as opposed to id<MKAnnotationView>?

    If so, then the problem is that [mapView annotations] returns an array of annotations (that is, objects that adopt the MKAnnotation protocol), and your for loop is casting those objects to MKAnnotationView, which then runs into problems. You could try:

    for (id <MKAnnotation> a in allPins) {
    

    …which would solve the problem where [mapView viewForAnnotation:a] is expecting a to be an object that adopts the MKAnnotation protocol, but is being sent an object that’s been cast to MKAnnotationView instead.

    You may also need to make sure your code for [self imageForSmallAnnotation:] is receiving the class of object it expects to receive, if and when you change what a is being cast to.

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

Sidebar

Related Questions

Is it possible to combine Underscore's filter and map? I currently have two separate
I currently have a simple list view adapter that holds two rows of text.
I have two activities one displaying map view and another listview, the main objective
I have a map view with thousand of items that i want to load
Currently have a custom Form Element View: class Apply_View_Helper_JQueryUiFormRadio extends Zend_View_Helper_FormElement My form is
I have an index view that lists all of the tags for my Entry
I have a grouped tableview that is populated with XML data in one section.
I currently have an app (in Silverlight), using mv-vm, that has an interface to
Currently I have tasked to prepare Document service for client side parser that user
I have multiple classes that I need to map into 1 class: This is

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.