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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:07:25+00:00 2026-06-17T05:07:25+00:00

For some reason my MKMapView gets an overlay sometimes that covers everything except the

  • 0

For some reason my MKMapView gets an overlay sometimes that covers everything except the view when loaded. You can scroll off to the side after the view loads and view the overlay. Additionally, this problem only exists in ios5 and below, this problem does not occur in ios6. I have found that if you zoom in or out on the map that the overlayed piece of the map will adjust to the new view. For example, if you zoom out then the non-overlayed piece of the map will adjust and get bigger to the new size of your view, but if you then scroll sideways, then the map is still all overlayed in the color defined in the viewForOverlay method. I have no idea why, have been working on this for a while, and Google didn’t turn anything up. Here is some of my code:

-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay {

    if([overlay class] == [MKPolyline class]){
    MKPolylineView *polylineView = [[MKPolylineView alloc] initWithPolyline:overlay];

    int lineSize = [self.ud integerForKey:@"lineSize"];
    polylineView.lineWidth = lineSize;

    NSString *lineColor = [self.ud objectForKey:@"lineColor"];

    if([lineColor isEqualToString:@"Red"]){
        polylineView.strokeColor = [UIColor redColor];
    }else if([lineColor isEqualToString:@"Blue"]){
        polylineView.strokeColor = [UIColor blueColor];
    }else if ([lineColor isEqualToString:@"Orange"]){
        polylineView.strokeColor = [UIColor orangeColor];
    }else if([lineColor isEqualToString:@"Green"]){
        polylineView.strokeColor = [UIColor greenColor];
    }else if([lineColor isEqualToString:@"Black"]){
        polylineView.strokeColor = [UIColor blackColor];
    }
    return polylineView;
    }else{
        MKOverlayView *overlayToReturn = [[MKOverlayView alloc]initWithOverlay:overlay];
        return overlayToReturn;
    }
}

This is what I get:

MKMapView

  • 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-17T05:07:26+00:00Added an answer on June 17, 2026 at 5:07 am

    I suspect the problem is with your creation of the MKPolyline or perhaps the lineSize setting. This code works fine here:

    #import <MapKit/MapKit.h>
    #import "ViewController.h"
    
    @implementation ViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        MKMapView *map = [[MKMapView alloc] initWithFrame:self.view.bounds];
        map.delegate = self;
        [self.view addSubview:map];
    
        CLLocationCoordinate2D coords[] = { {42,-83}, {32, -84}, {45,-78}, {42,-83} };
        MKPolyline *overlay = [MKPolyline polylineWithCoordinates:coords count:4];
        [map addOverlay:overlay];
    }
    
    -(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay {
    
        if([overlay class] == [MKPolyline class]){
        MKPolylineView *polylineView = [[MKPolylineView alloc] initWithPolyline:overlay];
    
        int lineSize = 2; //[self.ud integerForKey:@"lineSize"];
        polylineView.lineWidth = lineSize;
    
        NSString *lineColor = @"Red"; // [self.ud objectForKey:@"lineColor"];
    
        if([lineColor isEqualToString:@"Red"]){
            polylineView.strokeColor = [UIColor redColor];
        }else if([lineColor isEqualToString:@"Blue"]){
            polylineView.strokeColor = [UIColor blueColor];
        }else if ([lineColor isEqualToString:@"Orange"]){
            polylineView.strokeColor = [UIColor orangeColor];
        }else if([lineColor isEqualToString:@"Green"]){
            polylineView.strokeColor = [UIColor greenColor];
        }else if([lineColor isEqualToString:@"Black"]){
            polylineView.strokeColor = [UIColor blackColor];
        }
        return polylineView;
        }else{
            MKOverlayView *overlayToReturn = [[MKOverlayView alloc]initWithOverlay:overlay];
            return overlayToReturn;
        }
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason I can't horizontally scroll through my linear layout... I tried this
For some reason I can't detect I can't set a z index for any
For some reason there's a variable called d that is defined immediately after I
For some reason, my spec isn't passing. It appears that @categories isn't getting to
For some reason i can't seem to get this right ok i have 2
for some reason , i can't use jquery . this is my code: <!DOCTYPE
For some reason I can't get something to work. All I want to do
For some reason, I've always assumed that readonly fields have overhead associated with them,
For some reason, I can't access any of my variables after the first IF
For some odd reason the detail button somehow stopped appearing: - (MKAnnotationView *)mapView:(MKMapView *)mV

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.