问题
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:
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/
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