How to integrate Radar Overlay on MapView?

I want to integrate weather radar into my MapView. Please help us cope with this task. I have done so many search engines, but have not received success. Please check this image, which I wanted to do just that. enter image description here

+7
source share
2 answers

I did something similar to achieve this:

in the header file (.h)

@interface RDViewController : UIViewController{ UIImage *image ; } @property (strong, nonatomic) IBOutlet MKMapView *mapView; @property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator; @property (strong, nonatomic) IBOutlet UIImageView *imageView; 

in .m file

 @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. // eg 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 hereenter image description here

+3
source

You need to explore MapKit overlays ( MKOverlay ). In your case, you will create MKPolygon .

You will need to create an array of MKMapPoints from weather radar data, and then create MKPolygon from these points and add it as an overlay.

There is an example of an Apple project called HazardMap that does something very similar to what you are trying to do, except that in this case it uses earthquake data.

Also check out WWWDC 2011's presentation, "Visualizing Information Geographically with MapKit." About a 30-minute mark, they begin to talk about Overlays.

Hope this helps.

+2
source

All Articles