2012-03-05 1 views

答えて

3

私は、このタスクを達成するため、このような何かをやっています.Mファイルのヘッダー・ファイル内の

を(.H)

@interface RDViewController : UIViewController{ 

    UIImage *image ; 
} 
@property (strong, nonatomic) IBOutlet MKMapView *mapView; 

@property (strong, nonatomic) IBOutlet UIActivityIndicatorView *activityIndicator; 

@property (strong, nonatomic) IBOutlet UIImageView *imageView; 

@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

+0

どこからこのメソッドを取得しましたか?> MapOverlay * mapOverlay = [MapOverlay alloc] initWithImageData:[NSData dataWithContentsOfURL:url] withLowerLeftCoordinate:CLLocationCoordinate2Make(21.652538062803、-127.620375523875420)withUpperRightCoordinate:CLLocationCoordinate2Make (50.406626367301044、-66.517937876818)]; –

+0

これらのメソッドを含むカスタムクラスを作成する必要があります。これらのクラスの画像を確認してください。 –

+0

@iosRider mkoverlaysのアニメーションGIFに関連する質問をチェックアウトできますかhttp://stackoverflow.com/questions/20558591/animated-gif-in-an-mkmapview-overlay-using-mkoverlayrenderer – wigging

2

MapKitオーバーレイ(MKOverlay)を調べる必要があります。あなたの場合はMKPolygonを作成します。

気象レーダーデータからMKMapPointsの配列を作成し、これらの点からMKPolygonを作成し、オーバーレイとしてマップを追加する必要があります。

HazardMapと呼ばれるサンプルアップルプロジェクトがあります。このプロジェクトでは、地震データを使用している場合を除いて、何をしようとしているのと非常に似ています。

また、WWWDC 2011のプレゼンテーション「MapKitを使って地理的に情報を視覚化する」もチェックしてください。 30分ぐらいの間、彼らはオーバーレイについて語り始めます。

これが役に立ちます。

+0

はい私はHazardMapをチェックしましたが、気象情報を提供していないので、MyRequirement.Thanksとはいくつかの違いがありますが、応答はありがたいですが、このAPIはあります。 –

+1

ソース天気データにアクセスしたと仮定しました。 http://www.programmableweb.comを試して、必要なデータのソースを見つけることができます。 –

関連する問題