Last active
March 2, 2020 02:56
-
-
Save adonishi/8235292 to your computer and use it in GitHub Desktop.
iOS7 以降のMapKitで簡単に、地理院地図のタイルをオーバーレイさせる方法。
タイルのスタイルを変更する場合には、http://portal.cyberjapan.jp/help/development.html#h4-1 を参照
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ViewController : UIViewController <MKMapViewDelegate> { | |
IBOutlet MKMapView *mapView; | |
} | |
@property (nonatomic, retain) MKTileOverlay *tile_overlay; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
NSString *template = @"http://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png"; | |
MKTileOverlay *tile_overlay = [[MKTileOverlay alloc] initWithURLTemplate:template]; | |
tile_overlay.canReplaceMapContent = YES; | |
[self.mapView addOverlay:tile_overlay level:MKOverlayLevelAboveLabels]; | |
mapView.delegate = self; | |
} | |
-(MKTileOverlayRenderer *)mapView:(MKMapView*)mapView rendererForOverlay:(id<MKOverlay>)overlay { | |
return [[MKTileOverlayRenderer alloc] initWithOverlay:overlay]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment