पर कॉल करें मैं अपने स्वयं के टाइल्स के साथ Google बेसमैप को पूरी तरह से कवर करने के लिए कस्टम MKOverlay/MKOverlayView
का उपयोग कर रहा हूं, जो असीमित रूप से लोड होते हैं। मैं अनलोडेड टाइल्स का अनुरोध करने के पैटर्न का पालन करता हूं जब मुझे canDrawMapRect:zoomScale:
मेरे ओवरले व्यू (और उस मामले में FALSE लौटाते हुए) पर कॉल प्राप्त होता है, फिर टाइल उपलब्ध होने के बाद setNeedsDisplayInMapRect:zoomScale:
पर कॉल किया जाता है।setNeedsDisplayInMapRect नया drawMapRect ट्रिगर नहीं करता है:
यह सब आम तौर पर काम करता है, और सिम्युलेटर में पूरी तरह से काम करता प्रतीत होता है।
हालांकि, डिवाइस पर मुझे कभी-कभी ओवरले में 'छेद' मिलता है - एक लापता टाइल।
मैं देख सकता हूं कि टाइल का अनुरोध किया गया है, और अनुरोध पूरा हो गया है। मैं देख सकता हूं कि मैं setNeedsDisplayInMapRect:zoomScale:
पर कॉल करता हूं, और मैं मूल MKMapRect
और MKZoomScale
पास कर रहा हूं जो canDrawMapRect:zoomScale:
में प्रदान किए गए थे। लेकिन मैं यह भी देख सकता हूं कि उस टाइल को फिर से निकालने के लिए ओवरले को कभी भी नहीं पूछा जाता है (न तो canDrawMapRect:zoomScale:
और न ही drawMapRect:zoomScale:inContext:
को फिर से उस टाइल के लिए बुलाया जाता है)।
मुझे यह समझने की जरूरत है कि यह क्यों हो रहा है और इसे कैसे ठीक किया जाए।
यहाँ मेरी MKOverlayView उपवर्ग से प्रासंगिक कोड है:
- (BOOL) canDrawMapRect: (MKMapRect) mapRect zoomScale: (MKZoomScale) zoomScale
{
NSUInteger zoomLevel = [self zoomLevelForZoomScale:zoomScale];
CGPoint mercatorPoint = [self mercatorTileOriginForMapRect:mapRect];
NSUInteger tilex = floor(mercatorPoint.x * [self worldTileWidthForZoomLevel:zoomLevel]);
NSUInteger tiley = floor(mercatorPoint.y * [self worldTileWidthForZoomLevel:zoomLevel]);
NSURL* tileUrl = [self tileURLForZoomLevel: zoomLevel tileX: tilex tileY: tiley];
ASIHTTPRequest* tileRequest = [ASIHTTPRequest requestWithURL: tileUrl];
tileRequest.downloadCache = [ASIDownloadCache sharedCache];
[tileRequest setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
if (NO == [[ASIDownloadCache sharedCache] isCachedDataCurrentForRequest: tileRequest])
{
[tileRequest setCachePolicy: ASIAskServerIfModifiedWhenStaleCachePolicy];
tileRequest.delegate = self;
tileRequest.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
[NSValue value: &mapRect withObjCType: @encode(MKMapRect)], @"mapRect",
[NSValue value: &zoomScale withObjCType: @encode(MKZoomScale)], @"zoomScale",
[NSNumber numberWithInt: tilex], @"tilex",
[NSNumber numberWithInt: tiley], @"tiley",
nil];
[_tileRequestStack addOperation: tileRequest];
NSLog(@"canDrawMapRect: %d, %d - REQUESTING", tilex, tiley);
return NO;
}
NSLog(@"canDrawMapRect: %d, %d - READY", tilex, tiley);
return YES;
}
- (void) drawMapRect: (MKMapRect) mapRect zoomScale: (MKZoomScale) zoomScale inContext: (CGContextRef) context
{
NSUInteger zoomLevel = [self zoomLevelForZoomScale:zoomScale];
CGPoint mercatorPoint = [self mercatorTileOriginForMapRect:mapRect];
NSUInteger tilex = floor(mercatorPoint.x * [self worldTileWidthForZoomLevel:zoomLevel]);
NSUInteger tiley = floor(mercatorPoint.y * [self worldTileWidthForZoomLevel:zoomLevel]);
NSLog(@"drawMapRect: %d, %d", tilex, tiley);
NSURL* tileUrl = [self tileURLForZoomLevel: zoomLevel tileX: tilex tileY: tiley];
NSData* tileData = [[ASIDownloadCache sharedCache] cachedResponseDataForURL: tileUrl];
UIGraphicsPushContext(context);
if (tileData != nil)
{
UIImage* img = [UIImage imageWithData: tileData];
if (img != nil)
{
[img drawInRect: [self rectForMapRect: mapRect] blendMode: kCGBlendModeNormal alpha: 1.0 ];
}
else
{
NSLog(@"oops - no image");
}
CGSize s = CGContextConvertSizeToUserSpace(context, CGSizeMake(40, 1));
UIFont* f = [UIFont systemFontOfSize: s.width];
[[UIColor blackColor] setFill];
[[NSString stringWithFormat: @"%d,%d", tilex, tiley] drawInRect: [self rectForMapRect: mapRect] withFont: f];
}
UIGraphicsPopContext();
}
- (void) requestFinished: (ASIHTTPRequest *) tileRequest
{
NSValue* mapRectValue = [tileRequest.userInfo objectForKey: @"mapRect"];
MKMapRect mapRect; [mapRectValue getValue: &mapRect];
NSValue *zoomScaleValue = [tileRequest.userInfo objectForKey:@"zoomScale"];
MKZoomScale zoomScale; [zoomScaleValue getValue: &zoomScale];
NSLog(@"requestFinished: %d, %d, %lf",
[[tileRequest.userInfo objectForKey:@"tilex"] intValue],
[[tileRequest.userInfo objectForKey:@"tiley"] intValue],
zoomScale );
[self setNeedsDisplayInMapRect: mapRect zoomScale: zoomScale];
}
संपादित: I'm guessing that this is likely the issue.
हाय, क्या आपको कोई समाधान मिला? मुझे एक ही समस्या है :( – Igor
इस मुद्दे पर +1। –
क्या आपको लोगों को कोई समाधान मिला? –