我想在我的 MapView 上集成天气雷达。请任何人帮忙完成这项任务。我已经做了很多谷歌搜索但没有成功。请检查我想做的这张图片。
问问题
3111 次
2 回答
3
为了完成这项任务,我做了这样的事情:
在头文件(.h)中
@interface RDViewController : UIViewController{
UIImage *image ;
}
@property (strong, nonatomic) IBOutlet MKMapView *mapView;
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator;
@property (strong, nonatomic) IBOutlet UIImageView *imageView;
在 .m 文件中
@implementation RDViewController
@synthesize mapView;
@synthesize activityIndicator;
@synthesize imageView;
- (void)viewDidLoad
{
NSURL *url = [NSURL URLWithString:
@"http://radar.weather.gov/ridge/Conus/RadarImg/latest_radaronly.gif"];
MapOverlay * mapOverlay = [[MapOverlay alloc] initWithImageData:[NSData dataWithContentsOfURL:url] withLowerLeftCoordinate:CLLocationCoordinate2DMake(21.652538062803, -127.620375523875420) withUpperRightCoordinate:CLLocationCoordinate2DMake(50.406626367301044, -66.517937876818)];
//<LatLonBox><north>50.406626367301044</north><south>21.652538062803</south><east>-66.517937876818</east><west>-127.620375523875420</west></LatLonBox>
[mapView addOverlay:mapOverlay];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[self setImageView:nil];
[self setMapView:nil];
[self setActivityIndicator:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
#pragma Mark - MKOverlayDelgateMethods
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay {
MapOverlay *mapOverlay = overlay;
MapOverlayView *mapOverlayView = [[MapOverlayView alloc] initWithOverlay:mapOverlay];
return mapOverlayView;
}
于 2012-03-27T15:35:09.040 回答