Problems with RMMapView and Retina display

325 views
Skip to first unread message

Mark Rabenhorst

unread,
Oct 31, 2011, 9:40:44 PM10/31/11
to route-me
Has anyone else tested Route-me on a retina display? I have an an
interesting problem... when I load my app into a regular iPhone, the
highest level (10-11) tiles display without any problem. But for some
reason when I load the same exact version onto a retina display
iPhone, the top 2 layers don't show up. Instead, it shows the contents
of layer 12 and 13 respectively instead of 10 and 11. However, in both
cases I ask my RMMapView what zoom level they are at, and they both
say 11 - even though only the non-retina display actually shows the
right tiles.

Anyone else have this problem? I am using the mbtiles format for my
tile data.

Thanks!
-Mark

Billy Chan

unread,
Oct 31, 2011, 9:44:31 PM10/31/11
to route-...@googlegroups.com
have you tried the patch to support retina display?

2011/11/1 Mark Rabenhorst <mrabe...@internationalmapping.com>

--
You received this message because you are subscribed to the Google Groups "route-me" group.
To post to this group, send email to route-...@googlegroups.com.
To unsubscribe from this group, send email to route-me-map...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/route-me-map?hl=en.


Mark Rabenhorst

unread,
Oct 31, 2011, 10:07:28 PM10/31/11
to route-me
No, I didn't realize there was one...

On Oct 31, 9:44 pm, Billy Chan <waterfall...@gmail.com> wrote:
> have you tried the patch to support retina display?
>
> 2011/11/1 Mark Rabenhorst <mrabenho...@internationalmapping.com>

Mark Rabenhorst

unread,
Oct 31, 2011, 10:17:19 PM10/31/11
to route-me
I think I know what you're talking about now... I thought the patch
was already applied to the trunk (since it was back in October of last
year). Upon further research into my files, the changes were not
actually made. Even the current version of the code doesn't have those
changes.

Any reason for that? Or just never put in?

On Oct 31, 10:07 pm, Mark Rabenhorst

Mark Rabenhorst

unread,
Nov 1, 2011, 10:18:49 AM11/1/11
to route-me
So I applied the patch and no joy. In fact that patch didn't actually
change anything, so I had to manually change the code based off the
patch information.

What I find is that it doesn't matter if I use retina or regular, the
target zoom is always the same. I think that there must be something
wrong with this function in RMMapContents.m:

-(float) scaledMetersPerPixel
{
return [mercatorToScreenProjection metersPerPixel] / (double)
([[UIScreen mainScreen] respondsToSelector:@selector(scale)] ?
[[UIScreen mainScreen] scale] : 1.0);
}

Also... on the retina display, this is what I get for asking the
screen scale:
(gdb) p (double)[[UIScreen mainScreen] scale]
$5 = 5.3049894774131808e-315

Seems weird to me...

Any ideas?

-Mark

On Oct 31, 10:17 pm, Mark Rabenhorst

Mark Rabenhorst

unread,
Nov 1, 2011, 12:12:55 PM11/1/11
to route-me
I finally got it working, but I had to modify the code. The new code I
put in is:

-(float) scaledMetersPerPixel
{
float currScreenScale = (double)([[UIScreen mainScreen] scale] ==
2.0) ? 1.0 : 1.0;
float projMetersPerPixel = (float)[mercatorToScreenProjection
metersPerPixel];
float scaledMetersPerPixel = projMetersPerPixel*(currScreenScale);
return scaledMetersPerPixel;
}

Basically this is just complex code to return the projected
metersPerPixel. Unfortunately, using division by the mainScreen scale
gave me the wrong tileset (I needed 11 and it gave me 12 on retina).
This seems to work for me... but I am not sure how well it would work
for others. Increasing or decreasing the "true" 1.0 might make the map
scales a little sharper or blur them. But I found 1.0 to be pretty
much as good as I could get it.

I'm certainly open to any comments or suggestions. This just simply
works... but its probably not the best way to do it.

-Mark

On Nov 1, 10:18 am, Mark Rabenhorst

Jaroslav

unread,
Jan 29, 2012, 12:33:52 PM1/29/12
to route-...@googlegroups.com
Thanks a lot for your post! It saved me many hours :)

I want to contribute to it, and have edited it a little bit. It Your version on retina display it shows map with two times worse resolution. I have edited it to only show that on maximum zoom level. Other levels are shown as it is intended by route-me (it shows the next zoom level image, i.e. when you are viewing map with zoom level 15 on retina display, it actually shows tiles from 16 zoom level). 

Here is the code:

-(float) scaledMetersPerPixel {     
  if (currScreenScale > 1 && self.zoom +1 > maxZoom){  
    currScreenScale = 1.0;  
  }  
  float projMetersPerPixel = (float)[mercatorToScreenProjection metersPerPixel];  
  float scaledMetersPerPixel = projMetersPerPixel / currScreenScale;  
  return scaledMetersPerPixel;  
}
Reply all
Reply to author
Forward
0 new messages