mousebird-consulting-inc / WhirlyGlobe

WhirlyGlobe Development
Other
828 stars 254 forks source link

initWithParams: tileInfos do not work ,need help (ios) #1414

Closed zhujianyang closed 3 years ago

zhujianyang commented 3 years ago

hello,whirlyglobe team. version:2.6.5 when i use 2.6.5 to build app.I'm having some trouble。

WhirlyGlobeViewController globeViewC = nil; MaplyViewController mapViewC = nil; if ([theViewC isKindOfClass:[WhirlyGlobeViewController class]]) globeViewC = (WhirlyGlobeViewController )theViewC; else mapViewC = (MaplyViewController )theViewC;

NSString *cacheDir = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, true)[0];

MaplyRemoteTileInfoNew *tileInfo = [[MaplyRemoteTileInfoNew alloc] initWithBaseURL:@"http://t0.tianditu.gov.cn/img_w/wmts?service=wmts&request=gettile&version=1.0.0&layer=img&style=default&tilematrixset=w&format=tiles&tilematrix={z}&tilerow={x}&tilecol={y}&tk=21acecb607e8c575b1668c600606da16" minZoom:0 maxZoom:5];

tileInfo.cacheDir = thisCacheDir;

MaplyRemoteTileInfoNew *tileInfo1 = [[MaplyRemoteTileInfoNew alloc] initWithBaseURL:@"http://t0.tianditu.gov.cn/cia_w/wmts?service=wmts&request=gettile&version=1.0.0&layer=cia&style=default&tilematrixset=w&format=tiles&tilematrix={z}&tilerow={x}&tilecol={y}&tk=21acecb607e8c575b1668c600606da16" minZoom:0 maxZoom:5];

MaplySamplingParams *sampleParams = [[MaplySamplingParams alloc] init];
sampleParams.coordSys = [[MaplySphericalMercator alloc] initWebStandard];
sampleParams.coverPoles = true;
sampleParams.edgeMatching = true;
sampleParams.minZoom = tileInfo.minZoom;
sampleParams.maxZoom = tileInfo.maxZoom;
sampleParams.singleLevel = YES;

imageLoader.baseDrawPriority = kMaplyImageLayerDrawPriorityDefault;

imageLoader =[[MaplyQuadImageLoader alloc] initWithParams:sampleParams tileInfos:@[tileInfo,tileInfo1] viewC:theViewC];

if (globeViewC != nil) { globeViewC.height = 0.8; [globeViewC animateToPosition:MaplyCoordinateMakeWithDegrees(-122.4192,37.7793) time:1.0]; } else { mapViewC.height = 1.0; [mapViewC animateToPosition:MaplyCoordinateMakeWithDegrees(-122.4192,37.7793) time:1.0]; }

the first URL is Spherical Mercator projection,Image reproduction.the next URL is Mercator projection Image annotation i can not Get the desired effect is the URL wrong?

mousebird commented 3 years ago

I'd check that each tile source works individually first.

mousebird commented 3 years ago

For multiple tile sources, if you want to overlay them you'll need two QuadImageLoaders. Set the baseDrawPriority to kMaplyImageLayerDrawPriorityDefault in the first. Set the baseDrawPriority to kMaplyImageLayerDrawPriorityDefault+1 in the second. This should interleave the image sources.

mousebird commented 3 years ago

Oh and set drawPriorityPerLevel to 2 for both of them.

zhujianyang commented 3 years ago

thanks ,it works,but the effect is not I wanted,is there something wrong with the setting? 961627552286_ pic MaplyRemoteTileInfoNew *tileInfo = [[MaplyRemoteTileInfoNew alloc] initWithBaseURL:@"http://t0.tianditu.gov.cn/img_w/wmts?service=wmts&request=gettile&version=1.0.0&layer=img&format=tiles&tilematrixset=w&tk=eedb4905054fb3095d74ca98d7b7a584&tilecol={y}&tilerow={x}&tilematrix={z}" minZoom:1 maxZoom:5]; tileInfo.cacheDir = [NSString stringWithFormat:@"%@/daytexture-2017-09-26/", cacheDir];

tileInfo.cacheDir = thisCacheDir;

// Describes what the file covers and how deep
MaplySamplingParams *sampleParams = [[MaplySamplingParams alloc] init];
sampleParams.coordSys = [[MaplySphericalMercator alloc] initWebStandard];
sampleParams.coverPoles = true;
sampleParams.edgeMatching = true;
sampleParams.minZoom = tileInfo.minZoom;
sampleParams.maxZoom = tileInfo.maxZoom;
sampleParams.singleLevel = YES;

imageLoader = [[MaplyQuadImageLoader alloc] initWithParams:sampleParams tileInfo:tileInfo viewC:theViewC]; imageLoader.baseDrawPriority = kMaplyImageLayerDrawPriorityDefault;

due to the cache?or something?

zhujianyang commented 3 years ago

or need censium?