How can I add one big image as an overlay in Mapbox?

試著忘記壹切 提交于 2019-12-24 11:31:50

问题


I would like to add a tile source which is basically 1 PNG with a size of 800x800. I created a subclass of RMAbstractWebMapSource implementing the methods below but it doesn't work and I get a log error 'The tile source ... has a different tile side length than the tilesource container'.

@implementation CustomTileSource

- (NSURL *)URLForTile:(RMTile)tile
{
    return [[NSURL alloc] initWithString:@"THE_URL_OF_MY_PNG"];
}

- (NSString *)uniqueTilecacheKey
{
    return @"NLSMap";
}

- (NSString *)shortName
{
    return @"Map";
}
- (NSString *)longDescription
{
    return @"Test";
}
- (NSString *)shortAttribution
{
    return @"Google maps";
}
- (NSString *)longAttribution
{
    return @"Google maps";
}

- (float)minZoom
{
    return 7.0;
}

- (float)maxZoom
{
    return 11.0;
}

- (float)centerZoom
{
    return 8.0;
}

- (BOOL)coversFullWorld
{
    return NO;
}

- (CLLocationCoordinate2D)centerCoordinate
{
    return CLLocationCoordinate2DMake(33.3, -118.7);
}

- (RMSphericalTrapezium)latitudeLongitudeBoundingBox
{
    RMSphericalTrapezium bounds = {
        .southWest = {
            .longitude = -122.2,
            .latitude  = 30.29,
        },
        .northEast = {
            .longitude = -115.2,
            .latitude  = 36.209999999999994,
        },
    };

    return bounds;
}

- (NSUInteger)tileSideLength
{
    return 800.f;
}

- (BOOL)opaque
{
    return NO;
}

@end

Do you have an idea of how I could do it?

Thanks


回答1:


What you are doing requires providing map tiles according to the standard XYZ or TMS / Web Mercator tile schemes. You can't just provide a raster image and get it in the right place. You have a couple options:

  1. Use something like TileMill to render the raster image into map tiles. Here's a tutorial: https://www.mapbox.com/tilemill/docs/guides/reprojecting-geotiff/

  2. Look into this resource for native iOS functionality: https://github.com/mapbox/mapbox-ios-sdk/issues/361



来源:https://stackoverflow.com/questions/25149988/how-can-i-add-one-big-image-as-an-overlay-in-mapbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!