1
我想用MkMapView上的一組覆蓋引腳來構建整個世界的圖片。 爲了做到這一點,我嘗試我的算法如下: 截圖 將MkMapRegion設置爲地圖的下一部分,目前不在屏幕上 將所有截圖整理成一張大圖。通過整理構建完整的世界地圖MKMapview截圖
我有一個問題,因爲當我改變緯度時,MkMapView不能準確地將地圖居中在所需的點上,我設置的緯度與最終的緯度不同(根據相關的經度而變化)對於經度,我似乎能夠將地圖集中在我想要的點上。底線我似乎無法準確地重新創建整個世界地圖,因爲我截取了太多或太少的截圖。垂直
任何一個有建議
代碼片段在這裏:
dispatch_queue_t _queue2 = dispatch_queue_create("com.screenShots", DISPATCH_QUEUE_SERIAL);
dispatch_async(_queue2, ^{
int maxLatitudeScreens,maxLongitudeScreens;
if (UIUserInterfaceIdiomPad==UI_USER_INTERFACE_IDIOM()){
maxLatitudeScreens=SCREENS_LATITUDE_IPAD;
maxLongitudeScreens=SCREENS_LONGITUDE_IPAD;
}else{
maxLatitudeScreens=SCREENS_LATITUDE_IPHONE;
maxLongitudeScreens=SCREENS_LONGITUDE_IPHONE;
}
@synchronized(self){
for (int j=0; j<maxLongitudeScreens;j++){
for (int i=0 ; i<maxLatitudeScreens; i++) {
double latitudeDelta=45;
double longitudeDelta=180;
double latit=55.0-j*111.0;
double longit=-180.0+i*longitudeDelta*2/maxLatitudeScreens;
CLLocationCoordinate2D newCenter= CLLocationCoordinate2DMake(latit, longit);
MKCoordinateSpan theSpan= MKCoordinateSpanMake(latitudeDelta, longitudeDelta);
MKCoordinateRegion theRegion=MKCoordinateRegionMake(newCenter, theSpan);
[_contactMapView setRegion:theRegion animated:YES];
NSLog(@"latit=%f and longit=%f",_contactMapView.centerCoordinate.latitude, _contactMapView.centerCoordinate.longitude);
NSLog(@"mapviewCenterlatitude=%f and longitude=%f",_contactMapView.centerCoordinate.latitude, _contactMapView.centerCoordinate.longitude);
NSLog(@"latitudeSpan=%f and longitudeSpan=%f",_contactMapView.region.span.latitudeDelta, _contactMapView.region.span.longitudeDelta);
sleep(3);
[self screenshot:mapViewPrintFormatter.view];
sleep(1);
}
}
//UIImageWriteToSavedPhotosAlbum ([self collateImages],nil,nil,nil);
[self collateImages];
[self shareCollatedMapViewImage];
}
});
我最初試過,無濟於事。使用地區似乎有更多的控制,以顯示什麼元素的地圖顯示..任何其他想法? – Trantor