如何在MapView上集成Radar Overlay?

时间:2012-03-05 15:05:19

标签: ios ipad mkmapview weather-api radar-chart

我想在我的MapView上集成气象雷达。请任何人帮忙完成这项任务。我做了很多谷歌搜索但没有成功。请检查这个图像,我想这样做。 enter image description here

2 个答案:

答案 0 :(得分: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;

}

enter image description here enter image description here

答案 1 :(得分:2)

您需要调查MapKit叠加层(MKOverlay)。在您的情况下,您将创建MKPolygon

您需要从天气雷达数据中创建一个MKMapPoints数组,然后从这些点创建一个MKPolygon并将其作为叠加层添加到地图中。

有一个名为HazardMap的Apple项目示例,它与您尝试的操作非常相似,除非在这种情况下使用地震数据。

另请参阅WWWDC 2011演示文稿“使用MapKit在地理位置上可视化信息”。大约30分钟后,他们开始谈论叠加层。

希望这有帮助。