small medium large xlarge

Generic-user-small
16 Nov 2008, 12:12
mark tate (2 posts)

Hi Bill…

I have got the first copy of your book and I’ve put together a CATiledLayer with it’s own delegate but not using levelsOfDetail. My delegate’s drawLayer displays my tiles okay and zooms in and out, although very slow. When I set the set the levelsOfDetail of the tiled layer to cache the image and start zooming the tiles do not appear the right size and the tiles origin is in-correct.

It looks like I need to use the drawLayers context ref to and rescale the tile layer or tiles or something (autoresizingMask/contentMode flags ?)

What do I need to do in the drawLayer function to accomodate the levelsof Details. ?

Great book by the way, keep up the good work…

Biopic_100x100_pragsmall
16 Nov 2008, 12:53
Bill Dudney (917 posts)

Hi Mark,

Thanks for the kind words!

The ‘although very slow’ comment concerns me that something is not happing as it should. The drawing should happen very fast. Have you had a chance to compare your code to the code example from the book? That is a huge image (10MB jpeg) and it draws very quickly.

My suggestion would be to get the first part of the example working properly before trying to get the LOD into the mix.

Good luck and let me know when you get it working!

Generic-user-small
17 Nov 2008, 01:17
mark tate (2 posts)

Hi Bill..

I went back to the demo code and realized my mistake.

Naively I thought that my delegate was called for each tile that needed to be rendered. In fact as you example shows you need to work that out yourself based on the bounds and then iterate through the tiles that need to be displayed.

Now my example works with the levels of detail set…

In order to get a quick feedback to the user I am downloading small tiles to my own cache. I then load the tiles into a TiledLayer. Occasionally the TiledLayer seems to un-cache tiles of it’s own accord. As such you can see the layer redraw previously loaded tiles.. I see this in your demo as well.. I am thinking I can limit this un-desirable effect by joining together the smaller tiles to create bigger tiles, as they are downloaded. Is there anyway to control the tiled layer caching or how it is purged.

Keep you posted and thanks for the quick reply.

Biopic_100x100_pragsmall
17 Nov 2008, 12:28
Bill Dudney (917 posts)

Hi Mark,

Glad it worked!

As far as I know there is now way to control the caching behavior.

Good luck!

Generic-user-small
22 Nov 2008, 15:05
Preston Lewis (4 posts)

Hi Bill,

I have a quick question that I hope you can address. I am wanting to implement a similar functionality to what ‘mark tate’ in post #1 is doing but specifically for the iPhone. I am experiencing those same very slow performance issues. I know its been mentioned that CATiledLayer has some limitations. Can you elaborate on those limitations and if those limitations may be what I’m experiencing or just poor programming on my part? To be more specific, I’m using a PDF that’s under 600Kb in size and zooming in and out with tiling… and the performance is quite slow, I’m having problems believing this is due to functionality limitations.

Any direction or help is greatly appreciated!

Thanks in advance.

Biopic_100x100_pragsmall
24 Nov 2008, 12:33
Bill Dudney (917 posts)

Hi Preston,

I’m working on an example for my blog that I hope to get posted before the end of the week.

I have my sample app working and zooming and panning on the San Francisco Muni map, but it is a bit slow. I’ll be figuring out why its slow and see if I can make it faster and post before the end of the week.

Good Luck!

Generic-user-small
24 Nov 2008, 14:24
Preston Lewis (4 posts)

Bill,

Thank you very much. I certainly appreciate all your hard work and efforts. I look forward to what you’ll be coming up with, it’s always a treat!

Generic-user-small
03 Dec 2008, 05:29
Preston Lewis (4 posts)

Bill,

I wanted to touch base with you and see if you have made any progress with this issue? I have been searching high and low and have stumbled upon the following and wanted to get your insight or perhaps offer this for consideration. Thanks for your help.

http://code.google.com/p/route-me/

Generic-user-small
08 Dec 2008, 14:52
trey t (2 posts)

hello all, was wondering if there was a update to this thread? i looked at the route-me but that is to advanced for me, im trying to do a catiledlayer on either a pdf or large png for the iphone, but having problems finding good examples. any code to get me going is greatly appreciated, thanks for any insight.

Biopic_100x100_pragsmall
08 Dec 2008, 17:07
Bill Dudney (917 posts)

Hi Trey,

Blog post done here;

http://bill.dudney.net/roller/objc/entry/tiledlayer_on_the_iphone

Thanks for your interest!

Generic-user-small
08 Dec 2008, 19:28
trey t (2 posts)

Bill, thanks a million. Works great except for two issues: 1) the size of the UIView is infinite, so you can scroll as far left as you want to. Is there a way to fix this? I know in a scrollview you can set the ContentSize is there something similar in UIView? 2) the scrolling is jerky, but in your code you state its just for reference so thats probably why But all in all thanks for putting this out, a great help!!!!!

Biopic_100x100_pragsmall
08 Dec 2008, 19:58
Bill Dudney (917 posts)

Hi Trey,

Thanks for the kind words.

1) I did not use a scroll view but instead went with the simpler approach of just moving the sublayer around in the parent layer. To fix that you’d just have to code it up in the event management code to translate.

2) yeah, i looked at it for 10 minutes and figured it would be better to just get the code out there with a disclaimer instead of go through the extra time to make the event stuff perfect. I’m sure its some simple thing I over looked but with all the other stuff I have to get done…

Good luck!

Generic-user-small
21 Dec 2008, 20:53
Felix K. (4 posts)

Thanks for the code Bill!

Anyone make changes to the Event Management Code to make it work? Everything looks fine to me, and on the simulator its really smooth, but on the iPhone it’s very jerky.

Thanks, Felix

Generic-user-small
23 Dec 2008, 01:33
Felix K. (4 posts)

Anyone understand how the coordinate system of CATiledLayer works? I want to be able to zoom in on a touchEnded, but when i reposition the tiledLayer with the X,Y from the touch it’s way off.

When I debug the Y positions of the touches, or the tiledLayer are all negative.

I’m really confused about how all this works and the section in the book on Tiled Layers doesn’t really explain any of this. Can someone point me in the right direction.

Thanks, Felix

Biopic_100x100_pragsmall
23 Dec 2008, 03:57
Bill Dudney (917 posts)

Hi Felix,

Is your tiled layer in the scroll view or in a regular layer?

You need to have the tiled layer as a sublayer of a layer you can move the tiled layer around in. Keep in mind that the coord system of the tiled layer is going to be moved quite a bit off the container.

Happy to help but need more info.

TTFN

Generic-user-small
23 Dec 2008, 14:55
Felix K. (4 posts)

Hi Bill,

I figured it out…this is how i’m handling double tap (for anyone who wants the same functionality as maps.app):

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
	if(!moving) 
	{
		if(touches.count == 1) 
		{
			if([[touches anyObject] tapCount] == 2) 
			{
				CGPoint currentPoint = [[touches anyObject] locationInView:self];
				CGPoint delta = CGPointMake(currentPoint.x - tiledLayer.position.x, currentPoint.y - tiledLayer.position.y);
				
				tiledLayer.position = CGPointMake(tiledLayer.position.x - delta.x, tiledLayer.position.y - delta.y);
				[self zoomIn];
			}
		}
	} 
	else 
	{
		moving = NO;
	}
}
Generic-user-small
24 Dec 2008, 16:55
Felix K. (4 posts)

Does anyone have any examples of how to put a CATiledLayer inside a UIScrollView?

Thanks

Generic-user-small
19 Feb 2010, 06:00
Marc Alexander (1 post)

Hi Bill,

Good books, great videos. Love it.

I’m wondering why you are adding 1 in the drawLayer method below?

	NSInteger rowCount		= topRow - bottomRow + 1;
	NSInteger columnCount	= rightColumn - leftColumn + 1;

On the iPad simulator, this code fails until I remove the +1.

You must be logged in to comment