Skip to content

Instantly share code, notes, and snippets.

@adonishi
Last active March 2, 2020 02:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adonishi/8235292 to your computer and use it in GitHub Desktop.
Save adonishi/8235292 to your computer and use it in GitHub Desktop.
iOS7 以降のMapKitで簡単に、地理院地図のタイルをオーバーレイさせる方法。 タイルのスタイルを変更する場合には、http://portal.cyberjapan.jp/help/development.html#h4-1 を参照
@interface ViewController : UIViewController <MKMapViewDelegate> {
IBOutlet MKMapView *mapView;
}
@property (nonatomic, retain) MKTileOverlay *tile_overlay;
@end
- (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