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