2012-02-06 35 views
3

我試圖將透視變換應用於MKMapView。我下面的this Stackoverflow question的例子,所以我的代碼如下所示(插入視圖控制器的viewDidLoad法):將透視變換應用於MKMapView

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; 

這個代碼,寫,工作得很好,我得到歐洲地圖與應用的角度來看, 。問題是,如果我減少distance變量以獲得更接近的視圖,或者甚至從此工作初始狀態放大,則地圖不會正確放大,它只會縮放地圖,因爲它處於縮小狀態。另一方面,如果我沒有設置m34字段transform,即僅僅傾斜地圖而沒有透視圖,則它工作得很好。

有沒有一種方法可以獲得具有視角的街道級地圖?

回答

2

我設法透視加入

[map.layer setShouldRasterize:YES]; 

因此很明顯,有應用前景的時候是與地圖內容直接渲染問題的工作。