I am trying to apply a perspective transformation to an MKMapView
. I am following the example of this Stackoverflow question, so my code looks like this (inserted into the view controller's viewDidLoad
method):
MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
[self.view addSubview:map];
CLLocationDistance distance = 2000000.0;
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(52.5, 13.4);
[map setRegion:MKCoordinateRegionMakeWithDistance(coordinate, distance, distance)];
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -1200.0;
transform = CATransform3DRotate(transform, M_PI_4, 1.0, 0.0, 0.0);
map.layer.transform = transform;
This code, as written, works nicely, I get a map of Europe with the perspective applied. The problem is, if I decrease the distance
variable to get a closer view, or even zoom in from this working initial state, the map does not zoom in properly, it just scales the map as it was in the zoomed-out state. On the other hand, if I don't set the m34
field of transform
, i.e., only tilt the map without perspective, it works just fine.
Is there a way to get a street-level map with perspective?
I managed to get the perspective working by adding
[map.layer setShouldRasterize:YES];
So apparently there is a problem with direct rendering of the map content when perspective is applied.