如何在Mapbox中添加一个大图像作为叠加层? [英] How can I add one big image as an overlay in Mapbox?
问题描述
我想添加一个基本上是一个大小为800x800的PNG的瓦片源。
我创建了一个实现以下方法的RMAbstractWebMapSource的子类,但是它不起作用,我收到一个日志错误tile source ...具有不同于tileource容器的不同的tile边长度。
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
你有一个想法如何做?
谢谢
推荐答案
需要根据标准的XYZ或TMS / Web Mercator平铺方案提供地图图块。您不能只提供光栅图像并将其放在正确的位置。您有几个选项:
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/
查看本资源的原生iOS功能: https://github.com/mapbox/mapbox-ios-sdk/issues/361
Look into this resource for native iOS functionality: https://github.com/mapbox/mapbox-ios-sdk/issues/361
这篇关于如何在Mapbox中添加一个大图像作为叠加层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!