Added notification on new tile bounds
Showing
4 changed files
with
38 additions
and
2 deletions
@@ -125,6 +125,7 @@ enum { | @@ -125,6 +125,7 @@ enum { | ||
125 | - (void)zoomWithRMMercatorRectBounds:(RMXYRect)bounds; | 125 | - (void)zoomWithRMMercatorRectBounds:(RMXYRect)bounds; |
126 | 126 | ||
127 | - (CLLocationCoordinate2DBounds) getScreenCoordinateBounds; | 127 | - (CLLocationCoordinate2DBounds) getScreenCoordinateBounds; |
128 | +- (CLLocationCoordinate2DBounds) getCoordinateBounds:(CGRect) rect; | ||
128 | 129 | ||
129 | 130 | ||
130 | @end | 131 | @end |
@@ -563,15 +563,20 @@ static BOOL _performExpensiveOperations = YES; | @@ -563,15 +563,20 @@ static BOOL _performExpensiveOperations = YES; | ||
563 | 563 | ||
564 | - (CLLocationCoordinate2DBounds) getScreenCoordinateBounds | 564 | - (CLLocationCoordinate2DBounds) getScreenCoordinateBounds |
565 | { | 565 | { |
566 | - CLLocationCoordinate2DBounds bounds; | ||
567 | CGRect rect = [mercatorToScreenProjection screenBounds]; | 566 | CGRect rect = [mercatorToScreenProjection screenBounds]; |
568 | 567 | ||
568 | + return [self getCoordinateBounds:rect]; | ||
569 | +} | ||
570 | + | ||
571 | +- (CLLocationCoordinate2DBounds) getCoordinateBounds:(CGRect) rect | ||
572 | +{ | ||
573 | + CLLocationCoordinate2DBounds bounds; | ||
569 | CGPoint northWest = rect.origin; | 574 | CGPoint northWest = rect.origin; |
570 | 575 | ||
571 | CGPoint southEast; | 576 | CGPoint southEast; |
572 | southEast.x = rect.origin.x + rect.size.width; | 577 | southEast.x = rect.origin.x + rect.size.width; |
573 | southEast.y = rect.origin.y + rect.size.height; | 578 | southEast.y = rect.origin.y + rect.size.height; |
574 | - | 579 | + |
575 | NSLog(@"NortWest x:%lf y:%lf", northWest.x, northWest.y); | 580 | NSLog(@"NortWest x:%lf y:%lf", northWest.x, northWest.y); |
576 | NSLog(@"SouthEast x:%lf y:%lf", southEast.x, southEast.y); | 581 | NSLog(@"SouthEast x:%lf y:%lf", southEast.x, southEast.y); |
577 | 582 | ||
@@ -585,4 +590,5 @@ static BOOL _performExpensiveOperations = YES; | @@ -585,4 +590,5 @@ static BOOL _performExpensiveOperations = YES; | ||
585 | } | 590 | } |
586 | 591 | ||
587 | 592 | ||
593 | + | ||
588 | @end | 594 | @end |
@@ -17,6 +17,8 @@ | @@ -17,6 +17,8 @@ | ||
17 | 17 | ||
18 | #import "RMTileCache.h" | 18 | #import "RMTileCache.h" |
19 | 19 | ||
20 | +NSString * const RMMapNewTilesBoundsNotification = @"NewTilesBounds"; | ||
21 | + | ||
20 | NSString* const RMMapImageRemovedFromScreenNotification = @"RMMapImageRemovedFromScreen"; | 22 | NSString* const RMMapImageRemovedFromScreenNotification = @"RMMapImageRemovedFromScreen"; |
21 | NSString* const RMMapImageAddedToScreenNotification = @"RMMapImageAddedToScreen"; | 23 | NSString* const RMMapImageAddedToScreenNotification = @"RMMapImageAddedToScreen"; |
22 | 24 | ||
@@ -98,6 +100,31 @@ NSString* const RMResumeExpensiveOperations = @"RMResumeExpensiveOperations"; | @@ -98,6 +100,31 @@ NSString* const RMResumeExpensiveOperations = @"RMResumeExpensiveOperations"; | ||
98 | RMTileImageSet *images = [content imagesOnScreen]; | 100 | RMTileImageSet *images = [content imagesOnScreen]; |
99 | CGRect newLoadedBounds = [images addTiles:newTileRect ToDisplayIn:[content screenBounds]]; | 101 | CGRect newLoadedBounds = [images addTiles:newTileRect ToDisplayIn:[content screenBounds]]; |
100 | 102 | ||
103 | + //NSLog(@"===> TILES LOADED. X:%lf Y:%lf WIDTH:%lf HEIGHT:%lf",newLoadedBounds.origin.x, newLoadedBounds.origin.y, newLoadedBounds.size.width, newLoadedBounds.size.height); | ||
104 | + | ||
105 | + CLLocationCoordinate2DBounds locationBounds = [content getCoordinateBounds:newLoadedBounds]; | ||
106 | + | ||
107 | + //NSLog(@"===> AFTER CONVERSION - BOUNDS: NW Lat: %lf NW Lon:%lf SW Lat:%lf SW Lon:%lf", | ||
108 | + // locationBounds.northWest.latitude,locationBounds.northWest.longitude, | ||
109 | + // locationBounds.southEast.latitude, locationBounds.southEast.longitude); | ||
110 | + | ||
111 | + CLLocation *NWLocation = [[CLLocation alloc] initWithLatitude:locationBounds.northWest.latitude longitude:locationBounds.northWest.longitude]; | ||
112 | + CLLocation *SELocation = [[CLLocation alloc] initWithLatitude:locationBounds.southEast.latitude longitude:locationBounds.southEast.longitude]; | ||
113 | + | ||
114 | + NSArray *keys = [NSArray arrayWithObjects:@"NWBounds", @"SEBounds", nil]; | ||
115 | + NSArray *objects = [NSArray arrayWithObjects:NWLocation, SELocation, nil]; | ||
116 | + NSDictionary *tilesBounds = [NSDictionary dictionaryWithObjects:objects forKeys:keys]; | ||
117 | + | ||
118 | + [NWLocation release]; | ||
119 | + [SELocation release]; | ||
120 | + | ||
121 | + // Send notification | ||
122 | + [[NSNotificationCenter defaultCenter] postNotificationName:RMMapNewTilesBoundsNotification | ||
123 | + object:self | ||
124 | + userInfo:tilesBounds]; | ||
125 | + | ||
126 | + | ||
127 | + | ||
101 | if (!RMTileIsDummy(loadedTiles.origin.tile)) | 128 | if (!RMTileIsDummy(loadedTiles.origin.tile)) |
102 | [images removeTiles:loadedTiles]; | 129 | [images removeTiles:loadedTiles]; |
103 | 130 |
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | objects = { | 7 | objects = { |
8 | 8 | ||
9 | /* Begin PBXBuildFile section */ | 9 | /* Begin PBXBuildFile section */ |
10 | + 0913410D0EC816EE0017BB92 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B83E65630E80E81C001663B6 /* CoreLocation.framework */; }; | ||
10 | 126693040EB76C0B00E002D5 /* RMConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 126692A00EB75C0A00E002D5 /* RMConfiguration.m */; }; | 11 | 126693040EB76C0B00E002D5 /* RMConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 126692A00EB75C0A00E002D5 /* RMConfiguration.m */; }; |
11 | 1296F56B0EB8849A00FF25E0 /* RMMarkerStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 1296F55F0EB8743500FF25E0 /* RMMarkerStyle.h */; }; | 12 | 1296F56B0EB8849A00FF25E0 /* RMMarkerStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 1296F55F0EB8743500FF25E0 /* RMMarkerStyle.h */; }; |
12 | 1296F56C0EB8849B00FF25E0 /* RMMarkerStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 1296F5600EB8743500FF25E0 /* RMMarkerStyle.m */; }; | 13 | 1296F56C0EB8849B00FF25E0 /* RMMarkerStyle.m in Sources */ = {isa = PBXBuildFile; fileRef = 1296F5600EB8743500FF25E0 /* RMMarkerStyle.m */; }; |
@@ -255,6 +256,7 @@ | @@ -255,6 +256,7 @@ | ||
255 | B83E66C30E80F053001663B6 /* QuartzCore.framework in Frameworks */, | 256 | B83E66C30E80F053001663B6 /* QuartzCore.framework in Frameworks */, |
256 | B8C9787B0E8BE130007D16AD /* libMapView.a in Frameworks */, | 257 | B8C9787B0E8BE130007D16AD /* libMapView.a in Frameworks */, |
257 | B8474BC30EB401AF006A0BC1 /* libsqlite3.dylib in Frameworks */, | 258 | B8474BC30EB401AF006A0BC1 /* libsqlite3.dylib in Frameworks */, |
259 | + 0913410D0EC816EE0017BB92 /* CoreLocation.framework in Frameworks */, | ||
258 | ); | 260 | ); |
259 | runOnlyForDeploymentPostprocessing = 0; | 261 | runOnlyForDeploymentPostprocessing = 0; |
260 | }; | 262 | }; |
-
Please register or login to post a comment