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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:02:47+00:00 2026-05-30T09:02:47+00:00

When I draw a path with MKOverlays (sometimes with 5000+ individual MKPolylines), there is

  • 0

When I draw a path with MKOverlays (sometimes with 5000+ individual MKPolylines), there is a very long wait for all of the overlays to be drawn, and every time the map view is scrolled to a new area, the overlays for that area have to be drawn, and there is another noticeable freeze-up.

My dilemma is that I have two sets of code which both draw the path correctly. The first draws the path as one long line, and draws very quickly. The second draws each line segment as an individual line, and takes a long long time.

Now, why would I even consider the second way? Because I have to analyze each individual line to see what color the line should be. For example, if the line’s title property is “red”, then I make the line red, but if it is “blue”, then the line is blue. With the first technique, this kind of specificity is not possible (as far as I know, but maybe someone else knows differently?) because the path is just one big line, and accessing each individual segment is impossible. With the second way it is easy, but just takes a long time.

Here are my two sets of code:

First way (fast but can’t access individual segments):

CLLocationCoordinate2D coords[sizeOverlayLat];

for(int iii = 0; iii < sizeOverlayLat; iii++) {
    coords[iii].latitude = [[overlayLat objectAtIndex:iii] doubleValue];
    coords[iii].longitude = [[overlayLong objectAtIndex:iii] doubleValue];
}

MKPolyline* line = [MKPolyline polylineWithCoordinates:coords count:sizeOverlayLat];

[mapViewGlobal addOverlay:line];

Second way (slow but I can draw each line with a specific color):

NSMutableArray* lines = [NSMutableArray new];

for(int idx = 1; idx < sizeOverlayLat; idx++) {
    CLLocationCoordinate2D coords[2];
    coords[0].latitude = [[overlayLat objectAtIndex:(idx - 1)] doubleValue];
    coords[0].longitude = [[overlayLong objectAtIndex:(idx - 1)] doubleValue];

    coords[1].latitude = [[overlayLat objectAtIndex:idx] doubleValue];
    coords[1].longitude = [[overlayLong objectAtIndex:idx] doubleValue];

    MKPolyline* line = [MKPolyline polylineWithCoordinates:coords count:2];
    [line setTitle:[overlayColors objectAtIndex:idx]];
    [lines addObject:line];
}

[mapViewGlobal addOverlays:lines];

My question is: Can I get the performance of the first way with the control over each line that the second way provides me?

  • 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-30T09:02:49+00:00Added an answer on May 30, 2026 at 9:02 am

    You can definitely get such performance, but you would probably need to create your own overlay view.

    In that view, you can draw polylines by calling CGAddLineToPoint repeatedly, while skipping parts using CGMoveToPoint. Do this separately for each color and you’re done. So if you have 2 colors (red+blue), you would loop through your polygon twice, first drawing red (skipping blue pieces) and then drawing blue (skipping red pieces).

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

Sidebar

Related Questions

In my app, I need to draw a path where every coupe of frames,
This may be a very dumb question, but how do I draw a path
I have a mapping application that needs to draw a path, and then display
I need to draw text onto a window HDC along a circular path using
I'm trying to draw a polygon using c# and directx All I get is
basically i am trying to draw the path i.e road path. for that i
I want to make an application in which I can draw a path on
Hello i have designed a maze and i want to draw a path between
I'm having some trouble getting an object to follow a path that is drawn
I'm trying to draw closed path and fill it with some collor. Here the

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.