added tile debug labeling switch
Showing
3 changed files
with
44 additions
and
0 deletions
@@ -179,6 +179,38 @@ | @@ -179,6 +179,38 @@ | ||
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | + if (mapView.debugTiles) | ||
183 | + { | ||
184 | + UIGraphicsBeginImageContext(tileImage.size); | ||
185 | + | ||
186 | + CGContextRef debugContext = UIGraphicsGetCurrentContext(); | ||
187 | + | ||
188 | + CGRect debugRect = CGRectMake(0, 0, tileImage.size.width, tileImage.size.height); | ||
189 | + | ||
190 | + [tileImage drawInRect:debugRect]; | ||
191 | + | ||
192 | + CGColorRef color = CGColorCreateCopyWithAlpha([[UIColor redColor] CGColor], 0.25); | ||
193 | + | ||
194 | + UIFont *font = [UIFont systemFontOfSize:36]; | ||
195 | + | ||
196 | + CGContextSetStrokeColorWithColor(debugContext, color); | ||
197 | + CGContextSetLineWidth(debugContext, 5); | ||
198 | + | ||
199 | + CGContextStrokeRect(debugContext, debugRect); | ||
200 | + | ||
201 | + CGContextSetFillColorWithColor(debugContext, color); | ||
202 | + | ||
203 | + NSString *debugString = [NSString stringWithFormat:@"%i,%i,%i", zoom, x, y]; | ||
204 | + | ||
205 | + CGSize debugSize = [debugString sizeWithFont:font]; | ||
206 | + | ||
207 | + [debugString drawInRect:CGRectMake(5, 5, debugSize.width, debugSize.height) withFont:font]; | ||
208 | + | ||
209 | + tileImage = UIGraphicsGetImageFromCurrentImageContext(); | ||
210 | + | ||
211 | + UIGraphicsEndImageContext(); | ||
212 | + } | ||
213 | + | ||
182 | [tileImage drawInRect:rect]; | 214 | [tileImage drawInRect:rect]; |
183 | 215 | ||
184 | UIGraphicsPopContext(); | 216 | UIGraphicsPopContext(); |
@@ -144,6 +144,8 @@ typedef enum { | @@ -144,6 +144,8 @@ typedef enum { | ||
144 | /// subview for the background image displayed while tiles are loading. | 144 | /// subview for the background image displayed while tiles are loading. |
145 | @property (nonatomic, retain) UIView *backgroundView; | 145 | @property (nonatomic, retain) UIView *backgroundView; |
146 | 146 | ||
147 | +@property (nonatomic, assign) BOOL debugTiles; | ||
148 | + | ||
147 | #pragma mark - | 149 | #pragma mark - |
148 | #pragma mark Initializers | 150 | #pragma mark Initializers |
149 | 151 |
@@ -118,6 +118,7 @@ | @@ -118,6 +118,7 @@ | ||
118 | @synthesize enableClustering, positionClusterMarkersAtTheGravityCenter, clusterMarkerSize, clusterAreaSize; | 118 | @synthesize enableClustering, positionClusterMarkersAtTheGravityCenter, clusterMarkerSize, clusterAreaSize; |
119 | @synthesize adjustTilesForRetinaDisplay; | 119 | @synthesize adjustTilesForRetinaDisplay; |
120 | @synthesize missingTilesDepth; | 120 | @synthesize missingTilesDepth; |
121 | +@synthesize debugTiles; | ||
121 | 122 | ||
122 | #pragma mark - | 123 | #pragma mark - |
123 | #pragma mark Initialization | 124 | #pragma mark Initialization |
@@ -1561,6 +1562,15 @@ | @@ -1561,6 +1562,15 @@ | ||
1561 | return [[mercatorToTileProjection retain] autorelease]; | 1562 | return [[mercatorToTileProjection retain] autorelease]; |
1562 | } | 1563 | } |
1563 | 1564 | ||
1565 | +- (void)setDebugTiles:(BOOL)shouldDebug; | ||
1566 | +{ | ||
1567 | + debugTiles = shouldDebug; | ||
1568 | + | ||
1569 | + tiledLayerView.layer.contents = nil; | ||
1570 | + | ||
1571 | + [tiledLayerView.layer setNeedsDisplay]; | ||
1572 | +} | ||
1573 | + | ||
1564 | #pragma mark - | 1574 | #pragma mark - |
1565 | #pragma mark LatLng/Pixel translation functions | 1575 | #pragma mark LatLng/Pixel translation functions |
1566 | 1576 |
-
Please register or login to post a comment