MKOverlay ビューを使用して、独自のカスタム マップを Google ベース マップの上に重ねるアプリに取り組んでいます。ただし、次のようにマップを表示します。
ただし、以下に示すようにマップを表示する必要があります。
そして私のコードは次のとおりです:
- (NSArray *)tilesInMapRect:(MKMapRect)rect zoomScale:(MKZoomScale)scale
{
NSInteger z = zoomScaleToZoomLevel(scale);
NSInteger minX = floor((MKMapRectGetMinX(rect) * scale) / TILE_SIZE);
NSInteger maxX = floor((MKMapRectGetMaxX(rect) * scale) / TILE_SIZE);
NSInteger minY = floor((MKMapRectGetMinY(rect) * scale) / TILE_SIZE);
NSInteger maxY = floor((MKMapRectGetMaxY(rect) * scale) / TILE_SIZE);
NSMutableArray *tiles = nil;
NSInteger tilesAtZ = pow(2, z);
// NSLog(@"max x and max y is:::%d %d",maxX,maxY);
for (NSInteger x = minX; x <maxX; x++) {
for (NSInteger y = minY; y <maxY; y++) {
// OSM
//NSString *tileKey = [[NSString alloc] initWithFormat:@"%d/%d/%d", z, x, y]; // was flippedY
// NSInteger flippedY = abs(y + 1 - tilesAtZ);
// Google maps
NSString *tileKey = [[NSString alloc] initWithFormat:@"x=%d&y=%d&z=%d", x, y, z];
// NSString *tileKey = [[NSString alloc]
// initWithFormat:@"x=%d&y=%d&z=%d", x, flippedY, z];
if (!tiles) {
tiles = [NSMutableArray array];
}
NSLog(@"x y and z are:::%d %d %d",x,y,z);
MKMapRect frame = MKMapRectMake((double)(x * TILE_SIZE) / scale,
(double)(y * TILE_SIZE) / scale,
TILE_SIZE/scale,
TILE_SIZE/scale);
// NSLog(@"frame is::%f %f %f %f",(double)(x * TILE_SIZE) / scale,(double)(y * TILE_SIZE) / scale, TILE_SIZE / scale, TILE_SIZE / scale);
ImageTile *tile = [[ImageTile alloc] initWithFrame:frame path:tileKey];
[tiles addObject:tile];
[tile release];
[tileKey release];
}
}
// NSLog(@"tiles are ::%@",tiles);
return tiles;
}
必要な出力を得るのを手伝ってください。前もって感謝します。