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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:56:09+00:00 2026-06-13T05:56:09+00:00

I am using CATiledLayer to draw map tiles and when zooming it, I start

  • 0

I am using CATiledLayer to draw map tiles and when zooming it, I start to see some artifacts, which I guess, are caused by precision problem.

I scale my CATiledLayer up to 2^18 (262’144x), the artifacts start to appear at about 15’000x

I thought CoreAnimation would be smart enough to handle those large scales, but apparently not.

Before I start writing my tile engine implementation from scratch to handle this, I was wondering if you had any suggestion.

This is how I setup my layer:

self.tiledLayer.tileSize = CGSizeMake(256, 256);
self.tiledLayer.levelsOfDetail = 1;
self.tiledLayer.levelsOfDetailBias = 10000;

My example, drawing code is really simple:

- (void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)context
{
    CGRect rect = CGContextGetClipBoundingBox(context);
    CGContextSetFillColorWithColor(context, [NSColor colorWithCalibratedRed:((CGFloat)rand() / (CGFloat)RAND_MAX) green:((CGFloat)rand() / (CGFloat)RAND_MAX) blue:0 alpha:1].CGColor);
    CGContextFillRect(context, rect);
}

This is how I set the scale on the layer:

CGAffineTransform t = CGAffineTransformIdentity;

CGFloat scale = pow(2, self.zoomLevel); // self.zoomLevel ranges from 0 to 18
t = CGAffineTransformScale(t, scale, scale);

NSLog(@"%g", scale);

self.tiledLayer.affineTransform = t;

NOTE: I discovered that the artifacts appears only “far from the origin” of the layer. If I look the tiles near the origin, they are not deformed, if I look far from the origin (screenshot if from the center) it get worse.

Here is an example of the artifacts I see:

artefacts

  • 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-13T05:56:10+00:00Added an answer on June 13, 2026 at 5:56 am

    Ok, I just found a very simple solution while cooking, just modulo the scale to something reasonable and loop with a hint to the drawing code. So for example when the scale hits 64, reset it to 1 and give 64 to the drawing code, so when the scale is 2, the drawing code will pick tiles for the zoom at 128.

    I will try this tomorrow and see how I can work with CATiledLayer caching mechanism to ensure a smooth experience.

    EDIT: I just took a few minutes to try this method, but I effectively got a problem with caching, as when I set the scale back to a preview value, drawInContext isn’t called again. I tried calling setNeedsDisplay, but it kills the smoothness of the zoom and makes everything super slow.

    EDIT 2: After tinkering with this solution for a few hours, I was unable to get a smooth zooming and panning. I tried a simplistic approach drawing my tiles in a single NSView drawRect:, it works, but would require significant work to be smooth and fast. So I’m keeping this question open to suggestions.

    EDIT 3: I finally wrote my own implementation from scratch that doesn’t have this bug.

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

Sidebar

Related Questions

I have a large UIScrollView which contains a CATiledLayer which I'm using to draw
I am using CATiledLayer as backing layer for my UIView, which I have put
I want to draw markers on a zoomable UIView that's using UIScrollView and CATiledLayer.
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using Microsoft SQL Server 2005, is there any way to see when a table
Good day all; I am trying to manually (not using sublayers) draw images within
Here is the problem... I am using CA Tiled Layer to display a large
Using mercurial, I've run into an odd problem where a line from one committer
Using MVC2 I have an AJAX form which is posting to a bound model.
Using Delphi 2010. I am looking for (possibly) a function or procedure which can

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.