0

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;
}

必要な出力を得るのを手伝ってください。前もって感謝します。

4

1 に答える 1

0

次のように、初期領域をワールド (定数 MKMapRectWorld) に設定するだけです。

MKCoordinateRegion worldRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
map.region = worldRegion;

通常、このコードは、MKMapView を初期化する viewDidLoad: に配置します。

于 2013-10-10T19:47:57.770 に答える