Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop' into release

  • Loading branch information...
commit 9be2728dc65c8b709cdd0c8fdb90749b37a10ee1 2 parents a6441f6 + a0ae60a
@trasch trasch authored
View
55 MapView/Map/RMMBTilesSource.h
@@ -1,55 +0,0 @@
-//
-// RMMBTilesSource.h
-//
-// Created by Justin R. Miller on 6/18/10.
-// Copyright 2010, Code Sorcery Workshop, LLC and Development Seed, Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// * Neither the names of Code Sorcery Workshop, LLC or Development Seed,
-// Inc., nor the names of its contributors may be used to endorse or
-// promote products derived from this software without specific prior
-// written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// http://mbtiles.org
-//
-// See samples/MBTilesDemo for example usage
-//
-
-#import <Foundation/Foundation.h>
-
-#import "RMTileSource.h"
-
-#define kMBTilesDefaultTileSize 256
-#define kMBTilesDefaultMinTileZoom 0
-#define kMBTilesDefaultMaxTileZoom 22
-#define kMBTilesDefaultLatLonBoundingBox ((RMSphericalTrapezium){.northEast = {.latitude = 90, .longitude = 180}, .southWest = {.latitude = -90, .longitude = -180}})
-
-@interface RMMBTilesSource : NSObject <RMTileSource>
-
-- (id)initWithTileSetURL:(NSURL *)tileSetURL;
-
-- (BOOL)coversFullWorld;
-- (NSString *)legend;
-
-@end
View
359 MapView/Map/RMMBTilesSource.m
@@ -1,359 +0,0 @@
-//
-// RMMBTilesSource.m
-//
-// Created by Justin R. Miller on 6/18/10.
-// Copyright 2010, Code Sorcery Workshop, LLC and Development Seed, Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// * Neither the names of Code Sorcery Workshop, LLC or Development Seed,
-// Inc., nor the names of its contributors may be used to endorse or
-// promote products derived from this software without specific prior
-// written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-
-#import "RMMBTilesSource.h"
-#import "RMTileImage.h"
-#import "RMProjection.h"
-#import "RMFractalTileProjection.h"
-
-#import "FMDatabase.h"
-#import "FMDatabaseQueue.h"
-
-@implementation RMMBTilesSource
-{
- RMFractalTileProjection *tileProjection;
- FMDatabaseQueue *queue;
-}
-
-- (id)initWithTileSetURL:(NSURL *)tileSetURL
-{
- if ( ! (self = [super init]))
- return nil;
-
- tileProjection = [[RMFractalTileProjection alloc] initFromProjection:[self projection]
- tileSideLength:kMBTilesDefaultTileSize
- maxZoom:kMBTilesDefaultMaxTileZoom
- minZoom:kMBTilesDefaultMinTileZoom];
-
- queue = [[FMDatabaseQueue databaseQueueWithPath:[tileSetURL path]] retain];
-
- if ( ! queue)
- return nil;
-
- [queue inDatabase:^(FMDatabase *db) {
- [db setShouldCacheStatements:YES];
- }];
-
- return self;
-}
-
-- (void)cancelAllDownloads
-{
- // no-op
-}
-
-- (void)dealloc
-{
- [tileProjection release]; tileProjection = nil;
- [queue release]; queue = nil;
- [super dealloc];
-}
-
-- (NSUInteger)tileSideLength
-{
- return tileProjection.tileSideLength;
-}
-
-- (UIImage *)imageForTile:(RMTile)tile inCache:(RMTileCache *)tileCache
-{
- NSAssert4(((tile.zoom >= self.minZoom) && (tile.zoom <= self.maxZoom)),
- @"%@ tried to retrieve tile with zoomLevel %d, outside source's defined range %f to %f",
- self, tile.zoom, self.minZoom, self.maxZoom);
-
- NSInteger zoom = tile.zoom;
- NSInteger x = tile.x;
- NSInteger y = pow(2, zoom) - tile.y - 1;
-
- dispatch_async(dispatch_get_main_queue(), ^(void)
- {
- [[NSNotificationCenter defaultCenter] postNotificationName:RMTileRequested object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]];
- });
-
- __block UIImage *image;
-
- [queue inDatabase:^(FMDatabase *db)
- {
- FMResultSet *results = [db executeQuery:@"select tile_data from tiles where zoom_level = ? and tile_column = ? and tile_row = ?",
- [NSNumber numberWithShort:zoom],
- [NSNumber numberWithUnsignedInt:x],
- [NSNumber numberWithUnsignedInt:y]];
-
- if ([db hadError])
- image = [RMTileImage errorTile];
-
- [results next];
-
- NSData *data = [results dataForColumn:@"tile_data"];
-
- if ( ! data)
- image = [RMTileImage errorTile];
- else
- image = [UIImage imageWithData:data];
-
- [results close];
- }];
-
- dispatch_async(dispatch_get_main_queue(), ^(void)
- {
- [[NSNotificationCenter defaultCenter] postNotificationName:RMTileRetrieved object:[NSNumber numberWithUnsignedLongLong:RMTileKey(tile)]];
- });
-
- return image;
-}
-
-- (NSString *)tileURL:(RMTile)tile
-{
- return nil;
-}
-
-- (NSString *)tileFile:(RMTile)tile
-{
- return nil;
-}
-
-- (NSString *)tilePath
-{
- return nil;
-}
-
-- (RMFractalTileProjection *)mercatorToTileProjection
-{
- return [[tileProjection retain] autorelease];
-}
-
-- (RMProjection *)projection
-{
- return [RMProjection googleProjection];
-}
-
-- (float)minZoom
-{
- __block double minZoom;
-
- [queue inDatabase:^(FMDatabase *db)
- {
- FMResultSet *results = [db executeQuery:@"select min(zoom_level) from tiles"];
-
- if ([db hadError])
- minZoom = kMBTilesDefaultMinTileZoom;
-
- [results next];
-
- minZoom = [results doubleForColumnIndex:0];
-
- [results close];
- }];
-
- return minZoom;
-}
-
-- (float)maxZoom
-{
- __block double maxZoom;
-
- [queue inDatabase:^(FMDatabase *db)
- {
- FMResultSet *results = [db executeQuery:@"select max(zoom_level) from tiles"];
-
- if ([db hadError])
- maxZoom = kMBTilesDefaultMaxTileZoom;
-
- [results next];
-
- maxZoom = [results doubleForColumnIndex:0];
-
- [results close];
- }];
-
- return maxZoom;
-}
-
-- (void)setMinZoom:(float)aMinZoom
-{
- [tileProjection setMinZoom:aMinZoom];
-}
-
-- (void)setMaxZoom:(float)aMaxZoom
-{
- [tileProjection setMaxZoom:aMaxZoom];
-}
-
-- (RMSphericalTrapezium)latitudeLongitudeBoundingBox
-{
- __block RMSphericalTrapezium bounds = kMBTilesDefaultLatLonBoundingBox;
-
- [queue inDatabase:^(FMDatabase *db)
- {
- FMResultSet *results = [db executeQuery:@"select value from metadata where name = 'bounds'"];
-
- [results next];
-
- NSString *boundsString = [results stringForColumnIndex:0];
-
- [results close];
-
- if (boundsString)
- {
- NSArray *parts = [boundsString componentsSeparatedByString:@","];
-
- if ([parts count] == 4)
- {
- bounds.southWest.longitude = [[parts objectAtIndex:0] doubleValue];
- bounds.southWest.latitude = [[parts objectAtIndex:1] doubleValue];
- bounds.northEast.longitude = [[parts objectAtIndex:2] doubleValue];
- bounds.northEast.latitude = [[parts objectAtIndex:3] doubleValue];
- }
- }
- }];
-
- return bounds;
-}
-
-- (BOOL)coversFullWorld
-{
- RMSphericalTrapezium ownBounds = [self latitudeLongitudeBoundingBox];
- RMSphericalTrapezium defaultBounds = kMBTilesDefaultLatLonBoundingBox;
-
- if (ownBounds.southWest.longitude <= defaultBounds.southWest.longitude + 10 &&
- ownBounds.northEast.longitude >= defaultBounds.northEast.longitude - 10)
- return YES;
-
- return NO;
-}
-
-- (NSString *)legend
-{
- __block NSString *legend;
-
- [queue inDatabase:^(FMDatabase *db)
- {
- FMResultSet *results = [db executeQuery:@"select value from metadata where name = 'legend'"];
-
- if ([db hadError])
- legend = nil;
-
- [results next];
-
- legend = [results stringForColumn:@"value"];
-
- [results close];
- }];
-
- return legend;
-}
-
-- (void)didReceiveMemoryWarning
-{
- NSLog(@"*** didReceiveMemoryWarning in %@", [self class]);
-}
-
-- (NSString *)uniqueTilecacheKey
-{
- return [NSString stringWithFormat:@"MBTiles%@", [queue.path lastPathComponent]];
-}
-
-- (NSString *)shortName
-{
- __block NSString *shortName;
-
- [queue inDatabase:^(FMDatabase *db)
- {
- FMResultSet *results = [db executeQuery:@"select value from metadata where name = 'name'"];
-
- if ([db hadError])
- shortName = nil;
-
- [results next];
-
- shortName = [results stringForColumnIndex:0];
-
- [results close];
- }];
-
- return shortName;
-}
-
-- (NSString *)longDescription
-{
- __block NSString *description;
-
- [queue inDatabase:^(FMDatabase *db)
- {
- FMResultSet *results = [db executeQuery:@"select value from metadata where name = 'description'"];
-
- if ([db hadError])
- description = nil;
-
- [results next];
-
- description = [results stringForColumnIndex:0];
-
- [results close];
- }];
-
- return [NSString stringWithFormat:@"%@ - %@", [self shortName], description];
-}
-
-- (NSString *)shortAttribution
-{
- __block NSString *attribution;
-
- [queue inDatabase:^(FMDatabase *db)
- {
- FMResultSet *results = [db executeQuery:@"select value from metadata where name = 'attribution'"];
-
- if ([db hadError])
- attribution = @"Unknown MBTiles attribution";
-
- [results next];
-
- attribution = [results stringForColumnIndex:0];
-
- [results close];
- }];
-
- return attribution;
-}
-
-- (NSString *)longAttribution
-{
- return [NSString stringWithFormat:@"%@ - %@", [self shortName], [self shortAttribution]];
-}
-
-- (void)removeAllCachedImages
-{
- NSLog(@"*** removeAllCachedImages in %@", [self class]);
-}
-
-@end
View
73 MapView/Map/RMMapBoxSource.h
@@ -1,73 +0,0 @@
-//
-// RMMapBoxSource.h
-//
-// Created by Justin R. Miller on 5/17/11.
-// Copyright 2012 MapBox.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// * Neither the name of MapBox, nor the names of its contributors may be
-// used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// This source supports both tiles from MapBox Hosting as well as the open source,
-// self-hosted TileStream software.
-//
-// When initializing an instance, pass in valid TileJSON 2.0.0[1] as returned by
-// the MapBox Hosting API[2] or TileStream software[3].
-//
-// Example app at https://github.com/mapbox/mapbox-ios-example
-//
-// [1] https://github.com/mapbox/TileJSON/tree/master/2.0.0
-// [2] http://mapbox.com/hosting/api/
-// [3] https://github.com/mapbox/tilestream
-//
-// This class also supports initialization via the deprecated info dictionary
-// for backwards compatibility and for iOS < 5.0 where JSON serialization isn't
-// built into the SDK. Its use is discouraged.
-
-#import "RMAbstractWebMapSource.h"
-
-#define kMapBoxDefaultTileSize 256
-#define kMapBoxDefaultMinTileZoom 0
-#define kMapBoxDefaultMaxTileZoom 18
-#define kMapBoxDefaultLatLonBoundingBox ((RMSphericalTrapezium){ .northEast = { .latitude = 90, .longitude = 180 }, \
- .southWest = { .latitude = -90, .longitude = -180 } })
-
-@interface RMMapBoxSource : RMAbstractWebMapSource
-
-- (id)initWithReferenceURL:(NSURL *)referenceURL; // Designated initializer. Point to either a remote TileJSON spec or a local TileJSON or property list.
-
-//
-// You may also use just `init` to get MapBox Streets by default.
-//
-
-- (id)initWithTileJSON:(NSString *)tileJSON; // Initialize source with TileJSON.
-- (id)initWithInfo:(NSDictionary *)info; // Initialize source with properly list (deprecated).
-
-- (NSString *)legend; // HTML-formatted legend for this source, if any
-- (BOOL)coversFullWorld; // Regional or global coverage?
-
-@property (nonatomic, readonly, retain) NSDictionary *infoDictionary;
-
-@end
View
209 MapView/Map/RMMapBoxSource.m
@@ -1,209 +0,0 @@
-//
-// RMMapBoxSource.m
-//
-// Created by Justin R. Miller on 5/17/11.
-// Copyright 2012 MapBox.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// * Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in the
-// documentation and/or other materials provided with the distribution.
-//
-// * Neither the name of MapBox, nor the names of its contributors may be
-// used to endorse or promote products derived from this software
-// without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-
-#import "RMMapBoxSource.h"
-
-@interface RMMapBoxSource ()
-
-@property (nonatomic, retain) NSDictionary *infoDictionary;
-
-@end
-
-#pragma mark -
-
-@implementation RMMapBoxSource
-
-@synthesize infoDictionary;
-
-- (id)init
-{
- return [self initWithReferenceURL:[NSURL URLWithString:@"http://api.tiles.mapbox.com/v2/mapbox.mapbox-streets.json"]];
-}
-
-- (id)initWithTileJSON:(NSString *)tileJSON
-{
- if (self = [super init])
- {
- NSAssert([NSJSONSerialization class], @"JSON serialization not supported by SDK");
-
- infoDictionary = (NSDictionary *)[[NSJSONSerialization JSONObjectWithData:[tileJSON dataUsingEncoding:NSUTF8StringEncoding]
- options:0
- error:nil] retain];
- }
-
- return self;
-}
-
-- (id)initWithInfo:(NSDictionary *)info
-{
- WarnDeprecated();
-
- if ( ! (self = [super init]))
- return nil;
-
- infoDictionary = [[NSDictionary dictionaryWithDictionary:info] retain];
-
- return self;
-}
-
-- (id)initWithReferenceURL:(NSURL *)referenceURL
-{
- id dataObject;
-
- if ((dataObject = [NSString stringWithContentsOfURL:referenceURL encoding:NSUTF8StringEncoding error:nil]) && dataObject)
- return [self initWithTileJSON:dataObject];
-
- else if ((dataObject = [[[NSDictionary alloc] initWithContentsOfURL:referenceURL] autorelease]) && dataObject)
- return [self initWithInfo:dataObject];
-
- return nil;
-}
-
-- (void)dealloc
-{
- [infoDictionary release];
- [super dealloc];
-}
-
-#pragma mark
-
-- (NSURL *)URLForTile:(RMTile)tile
-{
- // flip y value per OSM-style
- //
- NSInteger zoom = tile.zoom;
- NSInteger x = tile.x;
- NSInteger y = tile.y;
-
- if ([self.infoDictionary objectForKey:@"scheme"] && [[self.infoDictionary objectForKey:@"scheme"] isEqual:@"tms"])
- y = pow(2, zoom) - tile.y - 1;
-
- NSString *tileURLString;
-
- if ([self.infoDictionary objectForKey:@"tiles"])
- tileURLString = [[self.infoDictionary objectForKey:@"tiles"] objectAtIndex:0];
-
- else
- tileURLString = [self.infoDictionary objectForKey:@"tileURL"];
-
- tileURLString = [tileURLString stringByReplacingOccurrencesOfString:@"{z}" withString:[[NSNumber numberWithInteger:zoom] stringValue]];
- tileURLString = [tileURLString stringByReplacingOccurrencesOfString:@"{x}" withString:[[NSNumber numberWithInteger:x] stringValue]];
- tileURLString = [tileURLString stringByReplacingOccurrencesOfString:@"{y}" withString:[[NSNumber numberWithInteger:y] stringValue]];
-
- return [NSURL URLWithString:tileURLString];
-}
-
-- (float)minZoom
-{
- return [[self.infoDictionary objectForKey:@"minzoom"] floatValue];
-}
-
-- (float)maxZoom
-{
- return [[self.infoDictionary objectForKey:@"maxzoom"] floatValue];
-}
-
-- (RMSphericalTrapezium)latitudeLongitudeBoundingBox
-{
- id bounds = [self.infoDictionary objectForKey:@"bounds"];
-
- NSArray *parts;
-
- if ([bounds isKindOfClass:[NSArray class]])
- parts = bounds;
-
- else
- parts = [bounds componentsSeparatedByString:@","];
-
- if ([parts count] == 4)
- {
- RMSphericalTrapezium bounds = {
- .southWest = {
- .longitude = [[parts objectAtIndex:0] doubleValue],
- .latitude = [[parts objectAtIndex:1] doubleValue],
- },
- .northEast = {
- .longitude = [[parts objectAtIndex:2] doubleValue],
- .latitude = [[parts objectAtIndex:3] doubleValue],
- },
- };
-
- return bounds;
- }
-
- return kMapBoxDefaultLatLonBoundingBox;
-}
-
-- (BOOL)coversFullWorld
-{
- RMSphericalTrapezium ownBounds = [self latitudeLongitudeBoundingBox];
- RMSphericalTrapezium defaultBounds = kMapBoxDefaultLatLonBoundingBox;
-
- if (ownBounds.southWest.longitude <= defaultBounds.southWest.longitude + 10 &&
- ownBounds.northEast.longitude >= defaultBounds.northEast.longitude - 10)
- return YES;
-
- return NO;
-}
-
-- (NSString *)legend
-{
- return [self.infoDictionary objectForKey:@"legend"];
-}
-
-- (NSString *)uniqueTilecacheKey
-{
- return [NSString stringWithFormat:@"MapBox-%@-%@", [self.infoDictionary objectForKey:@"id"], [self.infoDictionary objectForKey:@"version"]];
-}
-
-- (NSString *)shortName
-{
- return [self.infoDictionary objectForKey:@"name"];
-}
-
-- (NSString *)longDescription
-{
- return [self.infoDictionary objectForKey:@"description"];
-}
-
-- (NSString *)shortAttribution
-{
- return [self.infoDictionary objectForKey:@"attribution"];
-}
-
-- (NSString *)longAttribution
-{
- return [self shortAttribution];
-}
-
-@end
View
191 MapView/Map/RMMapView.m
@@ -151,13 +151,13 @@ @implementation RMMapView
CGPoint _lastDraggingTranslation;
RMAnnotation *_draggedAnnotation;
- CLLocationManager *locationManager;
- RMUserLocation *userLocation;
- BOOL showsUserLocation;
- RMUserTrackingMode userTrackingMode;
+ CLLocationManager *_locationManager;
+ RMUserLocation *_userLocation;
+ BOOL _showsUserLocation;
+ RMUserTrackingMode _userTrackingMode;
- UIImageView *userLocationTrackingView;
- UIImageView *userHeadingTrackingView;
+ UIImageView *_userLocationTrackingView;
+ UIImageView *_userHeadingTrackingView;
}
@synthesize decelerationMode = _decelerationMode;
@@ -172,7 +172,7 @@ @implementation RMMapView
@synthesize positionClusterMarkersAtTheGravityCenter = _positionClusterMarkersAtTheGravityCenter;
@synthesize clusterMarkerSize = _clusterMarkerSize, clusterAreaSize = _clusterAreaSize;
@synthesize adjustTilesForRetinaDisplay = _adjustTilesForRetinaDisplay;
-@synthesize userLocation, showsUserLocation, userTrackingMode;
+@synthesize userLocation = _userLocation, showsUserLocation = _showsUserLocation, userTrackingMode = _userTrackingMode;
@synthesize missingTilesDepth = _missingTilesDepth;
@synthesize debugTiles = _debugTiles;
@@ -350,10 +350,10 @@ - (void)dealloc
[_projection release]; _projection = nil;
[_mercatorToTileProjection release]; _mercatorToTileProjection = nil;
[self setTileCache:nil];
- [locationManager release]; locationManager = nil;
- [userLocation release]; userLocation = nil;
- [userLocationTrackingView release]; userLocationTrackingView = nil;
- [userHeadingTrackingView release]; userHeadingTrackingView = nil;
+ [_locationManager release]; _locationManager = nil;
+ [_userLocation release]; _userLocation = nil;
+ [_userLocationTrackingView release]; _userLocationTrackingView = nil;
+ [_userHeadingTrackingView release]; _userHeadingTrackingView = nil;
[super dealloc];
}
@@ -455,8 +455,6 @@ - (RMProjectedRect)fitProjectedRect:(RMProjectedRect)rect1 intoRect:(RMProjected
- (RMProjectedRect)projectedRectFromLatitudeLongitudeBounds:(RMSphericalTrapezium)bounds
{
- float pixelBuffer = kZoomRectPixelBuffer;
-
CLLocationCoordinate2D southWest = bounds.southWest;
CLLocationCoordinate2D northEast = bounds.northEast;
CLLocationCoordinate2D midpoint = {
@@ -481,18 +479,18 @@ - (RMProjectedRect)projectedRectFromLatitudeLongitudeBounds:(RMSphericalTrapeziu
if ((myPoint.x / self.bounds.size.width) < (myPoint.y / self.bounds.size.height))
{
- if ((myPoint.y / (self.bounds.size.height - pixelBuffer)) > 1)
+ if ((myPoint.y / self.bounds.size.height) > 1)
{
- zoomRect.size.width = self.bounds.size.width * (myPoint.y / (self.bounds.size.height - pixelBuffer));
- zoomRect.size.height = self.bounds.size.height * (myPoint.y / (self.bounds.size.height - pixelBuffer));
+ zoomRect.size.width = self.bounds.size.width * (myPoint.y / self.bounds.size.height);
+ zoomRect.size.height = self.bounds.size.height * (myPoint.y / self.bounds.size.height);
}
}
else
{
- if ((myPoint.x / (self.bounds.size.width - pixelBuffer)) > 1)
+ if ((myPoint.x / self.bounds.size.width) > 1)
{
- zoomRect.size.width = self.bounds.size.width * (myPoint.x / (self.bounds.size.width - pixelBuffer));
- zoomRect.size.height = self.bounds.size.height * (myPoint.x / (self.bounds.size.width - pixelBuffer));
+ zoomRect.size.width = self.bounds.size.width * (myPoint.x / self.bounds.size.width);
+ zoomRect.size.height = self.bounds.size.height * (myPoint.x / self.bounds.size.width);
}
}
@@ -885,8 +883,6 @@ - (void)zoomWithLatitudeLongitudeBoundsSouthWest:(CLLocationCoordinate2D)southWe
else
{
// Convert northEast/southWest into RMMercatorRect and call zoomWithBounds
- float pixelBuffer = kZoomRectPixelBuffer;
-
CLLocationCoordinate2D midpoint = {
.latitude = (northEast.latitude + southWest.latitude) / 2,
.longitude = (northEast.longitude + southWest.longitude) / 2
@@ -909,18 +905,18 @@ - (void)zoomWithLatitudeLongitudeBoundsSouthWest:(CLLocationCoordinate2D)southWe
if ((myPoint.x / self.bounds.size.width) < (myPoint.y / self.bounds.size.height))
{
- if ((myPoint.y / (self.bounds.size.height - pixelBuffer)) > 1)
+ if ((myPoint.y / self.bounds.size.height) > 1)
{
- zoomRect.size.width = self.bounds.size.width * (myPoint.y / (self.bounds.size.height - pixelBuffer));
- zoomRect.size.height = self.bounds.size.height * (myPoint.y / (self.bounds.size.height - pixelBuffer));
+ zoomRect.size.width = self.bounds.size.width * (myPoint.y / self.bounds.size.height);
+ zoomRect.size.height = self.bounds.size.height * (myPoint.y / self.bounds.size.height);
}
}
else
{
- if ((myPoint.x / (self.bounds.size.width - pixelBuffer)) > 1)
+ if ((myPoint.x / self.bounds.size.width) > 1)
{
- zoomRect.size.width = self.bounds.size.width * (myPoint.x / (self.bounds.size.width - pixelBuffer));
- zoomRect.size.height = self.bounds.size.height * (myPoint.x / (self.bounds.size.width - pixelBuffer));
+ zoomRect.size.width = self.bounds.size.width * (myPoint.x / self.bounds.size.width);
+ zoomRect.size.height = self.bounds.size.height * (myPoint.x / self.bounds.size.width);
}
}
@@ -1400,6 +1396,9 @@ - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)recognizer
// check whether our custom pan gesture recognizer should start recognizing the gesture
CALayer *hit = [_overlayView.layer hitTest:[recognizer locationInView:_overlayView]];
+ if ([hit isEqual:_overlayView.layer])
+ return NO;
+
if (!hit || ([hit respondsToSelector:@selector(enableDragging)] && ![(RMMarker *)hit enableDragging]))
return NO;
@@ -2440,10 +2439,10 @@ - (CGPoint)mapPositionForAnnotation:(RMAnnotation *)annotation
- (void)setShowsUserLocation:(BOOL)newShowsUserLocation
{
- if (newShowsUserLocation == showsUserLocation)
+ if (newShowsUserLocation == _showsUserLocation)
return;
- showsUserLocation = newShowsUserLocation;
+ _showsUserLocation = newShowsUserLocation;
if (newShowsUserLocation)
{
@@ -2452,18 +2451,18 @@ - (void)setShowsUserLocation:(BOOL)newShowsUserLocation
self.userLocation = [RMUserLocation annotationWithMapView:self coordinate:CLLocationCoordinate2DMake(0, 0) andTitle:nil];
- locationManager = [[CLLocationManager alloc] init];
- locationManager.headingFilter = 5;
- locationManager.delegate = self;
- [locationManager startUpdatingLocation];
+ _locationManager = [[CLLocationManager alloc] init];
+ _locationManager.headingFilter = 5;
+ _locationManager.delegate = self;
+ [_locationManager startUpdatingLocation];
}
else
{
- [locationManager stopUpdatingLocation];
- [locationManager stopUpdatingHeading];
- locationManager.delegate = nil;
- [locationManager release];
- locationManager = nil;
+ [_locationManager stopUpdatingLocation];
+ [_locationManager stopUpdatingHeading];
+ _locationManager.delegate = nil;
+ [_locationManager release];
+ _locationManager = nil;
if (_delegateHasDidStopLocatingUser)
[_delegate mapViewDidStopLocatingUser:self];
@@ -2489,23 +2488,23 @@ - (void)setShowsUserLocation:(BOOL)newShowsUserLocation
- (void)setUserLocation:(RMUserLocation *)newUserLocation
{
- if ( ! [newUserLocation isEqual:userLocation])
+ if ( ! [newUserLocation isEqual:_userLocation])
{
- [userLocation release];
- userLocation = [newUserLocation retain];
+ [_userLocation release];
+ _userLocation = [newUserLocation retain];
}
}
- (BOOL)isUserLocationVisible
{
- if (userLocation)
+ if (_userLocation)
{
- CGPoint locationPoint = [self mapPositionForAnnotation:userLocation];
+ CGPoint locationPoint = [self mapPositionForAnnotation:_userLocation];
- CGRect locationRect = CGRectMake(locationPoint.x - userLocation.location.horizontalAccuracy,
- locationPoint.y - userLocation.location.horizontalAccuracy,
- userLocation.location.horizontalAccuracy * 2,
- userLocation.location.horizontalAccuracy * 2);
+ CGRect locationRect = CGRectMake(locationPoint.x - _userLocation.location.horizontalAccuracy,
+ locationPoint.y - _userLocation.location.horizontalAccuracy,
+ _userLocation.location.horizontalAccuracy * 2,
+ _userLocation.location.horizontalAccuracy * 2);
return CGRectIntersectsRect([self bounds], locationRect);
}
@@ -2520,17 +2519,17 @@ - (void)setUserTrackingMode:(RMUserTrackingMode)mode
- (void)setUserTrackingMode:(RMUserTrackingMode)mode animated:(BOOL)animated
{
- if (mode == userTrackingMode)
+ if (mode == _userTrackingMode)
return;
- userTrackingMode = mode;
+ _userTrackingMode = mode;
- switch (userTrackingMode)
+ switch (_userTrackingMode)
{
case RMUserTrackingModeNone:
default:
{
- [locationManager stopUpdatingHeading];
+ [_locationManager stopUpdatingHeading];
[UIView animateWithDuration:(animated ? 0.5 : 0.0)
delay:0.0
@@ -2545,15 +2544,15 @@ - (void)setUserTrackingMode:(RMUserTrackingMode)mode animated:(BOOL)animated
}
completion:nil];
- if (userLocationTrackingView || userHeadingTrackingView)
+ if (_userLocationTrackingView || _userHeadingTrackingView)
{
- [userLocationTrackingView removeFromSuperview];
- userLocationTrackingView = nil;
- [userHeadingTrackingView removeFromSuperview];
- userHeadingTrackingView = nil;
+ [_userLocationTrackingView removeFromSuperview];
+ _userLocationTrackingView = nil;
+ [_userHeadingTrackingView removeFromSuperview];
+ _userHeadingTrackingView = nil;
}
- userLocation.layer.hidden = NO;
+ _userLocation.layer.hidden = NO;
break;
}
@@ -2561,17 +2560,17 @@ - (void)setUserTrackingMode:(RMUserTrackingMode)mode animated:(BOOL)animated
{
self.showsUserLocation = YES;
- [locationManager stopUpdatingHeading];
+ [_locationManager stopUpdatingHeading];
if (self.userLocation)
- [self locationManager:locationManager didUpdateToLocation:self.userLocation.location fromLocation:self.userLocation.location];
+ [self locationManager:_locationManager didUpdateToLocation:self.userLocation.location fromLocation:self.userLocation.location];
- if (userLocationTrackingView || userHeadingTrackingView)
+ if (_userLocationTrackingView || _userHeadingTrackingView)
{
- [userLocationTrackingView removeFromSuperview];
- userLocationTrackingView = nil;
- [userHeadingTrackingView removeFromSuperview];
- userHeadingTrackingView = nil;
+ [_userLocationTrackingView removeFromSuperview];
+ _userLocationTrackingView = nil;
+ [_userHeadingTrackingView removeFromSuperview];
+ _userHeadingTrackingView = nil;
}
[UIView animateWithDuration:(animated ? 0.5 : 0.0)
@@ -2587,7 +2586,7 @@ - (void)setUserTrackingMode:(RMUserTrackingMode)mode animated:(BOOL)animated
}
completion:nil];
- userLocation.layer.hidden = NO;
+ _userLocation.layer.hidden = NO;
break;
}
@@ -2595,63 +2594,63 @@ - (void)setUserTrackingMode:(RMUserTrackingMode)mode animated:(BOOL)animated
{
self.showsUserLocation = YES;
- userLocation.layer.hidden = YES;
+ _userLocation.layer.hidden = YES;
- userHeadingTrackingView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HeadingAngleSmall.png"]];
+ _userHeadingTrackingView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HeadingAngleSmall.png"]];
- userHeadingTrackingView.center = CGPointMake(round([self bounds].size.width / 2),
- round([self bounds].size.height / 2) - (userHeadingTrackingView.bounds.size.height / 2) - 4);
+ _userHeadingTrackingView.center = CGPointMake(round([self bounds].size.width / 2),
+ round([self bounds].size.height / 2) - (_userHeadingTrackingView.bounds.size.height / 2) - 4);
- userHeadingTrackingView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
- UIViewAutoresizingFlexibleRightMargin |
- UIViewAutoresizingFlexibleTopMargin |
- UIViewAutoresizingFlexibleBottomMargin;
+ _userHeadingTrackingView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
+ UIViewAutoresizingFlexibleRightMargin |
+ UIViewAutoresizingFlexibleTopMargin |
+ UIViewAutoresizingFlexibleBottomMargin;
- userHeadingTrackingView.alpha = 0.0;
+ _userHeadingTrackingView.alpha = 0.0;
- [self addSubview:userHeadingTrackingView];
+ [self addSubview:_userHeadingTrackingView];
- [UIView animateWithDuration:0.5 animations:^(void) { userHeadingTrackingView.alpha = 1.0; }];
+ [UIView animateWithDuration:0.5 animations:^(void) { _userHeadingTrackingView.alpha = 1.0; }];
- userLocationTrackingView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TrackingDot.png"]];
+ _userLocationTrackingView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TrackingDot.png"]];
- userLocationTrackingView.center = CGPointMake(round([self bounds].size.width / 2),
+ _userLocationTrackingView.center = CGPointMake(round([self bounds].size.width / 2),
round([self bounds].size.height / 2));
- userLocationTrackingView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
- UIViewAutoresizingFlexibleRightMargin |
- UIViewAutoresizingFlexibleTopMargin |
- UIViewAutoresizingFlexibleBottomMargin;
+ _userLocationTrackingView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin |
+ UIViewAutoresizingFlexibleRightMargin |
+ UIViewAutoresizingFlexibleTopMargin |
+ UIViewAutoresizingFlexibleBottomMargin;
- [self addSubview:userLocationTrackingView];
+ [self addSubview:_userLocationTrackingView];
if (self.zoom < 3)
[self zoomByFactor:exp2f(3 - [self zoom]) near:self.center animated:YES];
if (self.userLocation)
- [self locationManager:locationManager didUpdateToLocation:self.userLocation.location fromLocation:self.userLocation.location];
+ [self locationManager:_locationManager didUpdateToLocation:self.userLocation.location fromLocation:self.userLocation.location];
- [locationManager startUpdatingHeading];
+ [_locationManager startUpdatingHeading];
break;
}
}
if (_delegateHasDidChangeUserTrackingMode)
- [_delegate mapView:self didChangeUserTrackingMode:userTrackingMode animated:animated];
+ [_delegate mapView:self didChangeUserTrackingMode:_userTrackingMode animated:animated];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
- if ( ! showsUserLocation || _mapScrollView.isDragging)
+ if ( ! _showsUserLocation || _mapScrollView.isDragging)
return;
if ([newLocation distanceFromLocation:oldLocation])
{
- userLocation.location = newLocation;
+ _userLocation.location = newLocation;
if (_delegateHasDidUpdateUserLocation)
- [_delegate mapView:self didUpdateUserLocation:userLocation];
+ [_delegate mapView:self didUpdateUserLocation:_userLocation];
}
if (self.userTrackingMode != RMUserTrackingModeNone)
@@ -2659,7 +2658,7 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLoca
// zoom centered on user location unless we're already centered there (or very close)
//
CGPoint mapCenterPoint = [self convertPoint:self.center fromView:self.superview];
- CGPoint userLocationPoint = [self mapPositionForAnnotation:userLocation];
+ CGPoint userLocationPoint = [self mapPositionForAnnotation:_userLocation];
if (fabsf(userLocationPoint.x - mapCenterPoint.x) > 2 || fabsf(userLocationPoint.y - mapCenterPoint.y > 2))
{
@@ -2762,14 +2761,14 @@ - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLoca
if ([newLocation distanceFromLocation:oldLocation])
trackingHaloAnnotation.coordinate = newLocation.coordinate;
- userLocation.layer.hidden = ((trackingHaloAnnotation.coordinate.latitude == 0 && trackingHaloAnnotation.coordinate.longitude == 0) || self.userTrackingMode == RMUserTrackingModeFollowWithHeading);
+ _userLocation.layer.hidden = ((trackingHaloAnnotation.coordinate.latitude == 0 && trackingHaloAnnotation.coordinate.longitude == 0) || self.userTrackingMode == RMUserTrackingModeFollowWithHeading);
accuracyCircleAnnotation.layer.hidden = newLocation.horizontalAccuracy <= 10;
trackingHaloAnnotation.layer.hidden = ((trackingHaloAnnotation.coordinate.latitude == 0 && trackingHaloAnnotation.coordinate.longitude == 0) || newLocation.horizontalAccuracy > 10);
- if ( ! [_annotations containsObject:userLocation])
- [self addAnnotation:userLocation];
+ if ( ! [_annotations containsObject:_userLocation])
+ [self addAnnotation:_userLocation];
}
- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)manager
@@ -2779,13 +2778,13 @@ - (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)mana
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
- if ( ! showsUserLocation || _mapScrollView.isDragging)
+ if ( ! _showsUserLocation || _mapScrollView.isDragging)
return;
- userLocation.heading = newHeading;
+ _userLocation.heading = newHeading;
if (_delegateHasDidUpdateUserLocation)
- [_delegate mapView:self didUpdateUserLocation:userLocation];
+ [_delegate mapView:self didUpdateUserLocation:_userLocation];
if (newHeading.trueHeading != 0 && self.userTrackingMode == RMUserTrackingModeFollowWithHeading)
{
View
24 MapView/Map/RMUserLocation.m
@@ -12,9 +12,9 @@
@implementation RMUserLocation
-@synthesize updating;
-@synthesize location;
-@synthesize heading;
+@synthesize updating = _updating;
+@synthesize location = _location;
+@synthesize heading = _heading;
- (id)initWithMapView:(RMMapView *)aMapView coordinate:(CLLocationCoordinate2D)aCoordinate andTitle:(NSString *)aTitle
{
@@ -36,8 +36,8 @@ - (void)dealloc
{
[layer release]; layer = nil;
[annotationType release]; annotationType = nil;
- [location release]; location = nil;
- [heading release]; heading = nil;
+ [_location release]; _location = nil;
+ [_heading release]; _heading = nil;
[super dealloc];
}
@@ -48,23 +48,23 @@ - (BOOL)isUpdating
- (void)setLocation:(CLLocation *)newLocation
{
- if ([newLocation distanceFromLocation:location] && newLocation.coordinate.latitude != 0 && newLocation.coordinate.longitude != 0)
+ if ([newLocation distanceFromLocation:_location] && newLocation.coordinate.latitude != 0 && newLocation.coordinate.longitude != 0)
{
[self willChangeValueForKey:@"location"];
- [location release];
- location = [newLocation retain];
- self.coordinate = location.coordinate;
+ [_location release];
+ _location = [newLocation retain];
+ self.coordinate = _location.coordinate;
[self didChangeValueForKey:@"location"];
}
}
- (void)setHeading:(CLHeading *)newHeading
{
- if (newHeading.trueHeading != heading.trueHeading)
+ if (newHeading.trueHeading != _heading.trueHeading)
{
[self willChangeValueForKey:@"heading"];
- [heading release];
- heading = [newHeading retain];
+ [_heading release];
+ _heading = [newHeading retain];
[self didChangeValueForKey:@"heading"];
}
}
View
90 MapView/Map/RMUserTrackingBarButtonItem.m
@@ -34,39 +34,39 @@ - (void)changeMode:(id)sender;
@implementation RMUserTrackingBarButtonItem
@synthesize mapView = _mapView;
-@synthesize segmentedControl;
-@synthesize buttonImageView;
-@synthesize activityView;
-@synthesize state;
+@synthesize segmentedControl = _segmentedControl;
+@synthesize buttonImageView = _buttonImageView;
+@synthesize activityView = _activityView;
+@synthesize state = _state;
- (id)initWithMapView:(RMMapView *)mapView
{
if ( ! (self = [super initWithCustomView:[[UIControl alloc] initWithFrame:CGRectMake(0, 0, 32, 32)]]))
return nil;
- segmentedControl = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@""]] retain];
- segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
- [segmentedControl setWidth:32.0 forSegmentAtIndex:0];
- segmentedControl.userInteractionEnabled = NO;
- segmentedControl.tintColor = self.tintColor;
- segmentedControl.center = self.customView.center;
+ _segmentedControl = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@""]] retain];
+ _segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
+ [_segmentedControl setWidth:32.0 forSegmentAtIndex:0];
+ _segmentedControl.userInteractionEnabled = NO;
+ _segmentedControl.tintColor = self.tintColor;
+ _segmentedControl.center = self.customView.center;
- [self.customView addSubview:segmentedControl];
+ [self.customView addSubview:_segmentedControl];
- buttonImageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TrackingLocation.png"]] retain];
- buttonImageView.contentMode = UIViewContentModeCenter;
- buttonImageView.frame = CGRectMake(0, 0, 32, 32);
- buttonImageView.center = self.customView.center;
- buttonImageView.userInteractionEnabled = NO;
+ _buttonImageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"TrackingLocation.png"]] retain];
+ _buttonImageView.contentMode = UIViewContentModeCenter;
+ _buttonImageView.frame = CGRectMake(0, 0, 32, 32);
+ _buttonImageView.center = self.customView.center;
+ _buttonImageView.userInteractionEnabled = NO;
- [self.customView addSubview:buttonImageView];
+ [self.customView addSubview:_buttonImageView];
- activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] retain];
- activityView.hidesWhenStopped = YES;
- activityView.center = self.customView.center;
- activityView.userInteractionEnabled = NO;
+ _activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite] retain];
+ _activityView.hidesWhenStopped = YES;
+ _activityView.center = self.customView.center;
+ _activityView.userInteractionEnabled = NO;
- [self.customView addSubview:activityView];
+ [self.customView addSubview:_activityView];
[((UIControl *)self.customView) addTarget:self action:@selector(changeMode:) forControlEvents:UIControlEventTouchUpInside];
@@ -75,7 +75,7 @@ - (id)initWithMapView:(RMMapView *)mapView
[_mapView addObserver:self forKeyPath:@"userTrackingMode" options:NSKeyValueObservingOptionNew context:nil];
[_mapView addObserver:self forKeyPath:@"userLocation.location" options:NSKeyValueObservingOptionNew context:nil];
- state = RMUserTrackingButtonStateLocation;
+ _state = RMUserTrackingButtonStateLocation;
[self updateAppearance];
@@ -84,9 +84,9 @@ - (id)initWithMapView:(RMMapView *)mapView
- (void)dealloc
{
- [segmentedControl release]; segmentedControl = nil;
- [buttonImageView release]; buttonImageView = nil;
- [activityView release]; activityView = nil;
+ [_segmentedControl release]; _segmentedControl = nil;
+ [_buttonImageView release]; _buttonImageView = nil;
+ [_activityView release]; _activityView = nil;
[_mapView removeObserver:self forKeyPath:@"userTrackingMode"];
[_mapView removeObserver:self forKeyPath:@"userLocation.location"];
[_mapView release]; _mapView = nil;
@@ -116,7 +116,7 @@ - (void)setTintColor:(UIColor *)newTintColor
{
[super setTintColor:newTintColor];
- segmentedControl.tintColor = newTintColor;
+ _segmentedControl.tintColor = newTintColor;
}
#pragma mark -
@@ -132,7 +132,7 @@ - (void)updateAppearance
{
// "selection" state
//
- segmentedControl.selectedSegmentIndex = (_mapView.userTrackingMode == RMUserTrackingModeNone ? UISegmentedControlNoSegment : 0);
+ _segmentedControl.selectedSegmentIndex = (_mapView.userTrackingMode == RMUserTrackingModeNone ? UISegmentedControlNoSegment : 0);
// activity/image state
//
@@ -145,28 +145,28 @@ - (void)updateAppearance
options:UIViewAnimationOptionBeginFromCurrentState
animations:^(void)
{
- buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
- activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
+ _buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
+ _activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
}
completion:^(BOOL finished)
{
- buttonImageView.hidden = YES;
+ _buttonImageView.hidden = YES;
- [activityView startAnimating];
+ [_activityView startAnimating];
[UIView animateWithDuration:0.25 animations:^(void)
{
- buttonImageView.transform = CGAffineTransformIdentity;
- activityView.transform = CGAffineTransformIdentity;
+ _buttonImageView.transform = CGAffineTransformIdentity;
+ _activityView.transform = CGAffineTransformIdentity;
}];
}];
- state = RMUserTrackingButtonStateActivity;
+ _state = RMUserTrackingButtonStateActivity;
}
else
{
- if ((_mapView.userTrackingMode != RMUserTrackingModeFollowWithHeading && state != RMUserTrackingButtonStateLocation) ||
- (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading && state != RMUserTrackingButtonStateHeading))
+ if ((_mapView.userTrackingMode != RMUserTrackingModeFollowWithHeading && _state != RMUserTrackingButtonStateLocation) ||
+ (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading && _state != RMUserTrackingButtonStateHeading))
{
// if image state doesn't match mode, update it
//
@@ -175,24 +175,24 @@ - (void)updateAppearance
options:UIViewAnimationOptionBeginFromCurrentState
animations:^(void)
{
- buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
- activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
+ _buttonImageView.transform = CGAffineTransformMakeScale(0.01, 0.01);
+ _activityView.transform = CGAffineTransformMakeScale(0.01, 0.01);
}
completion:^(BOOL finished)
{
- buttonImageView.image = [UIImage imageNamed:(_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? @"TrackingHeading.png" : @"TrackingLocation.png")];
- buttonImageView.hidden = NO;
+ _buttonImageView.image = [UIImage imageNamed:(_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? @"TrackingHeading.png" : @"TrackingLocation.png")];
+ _buttonImageView.hidden = NO;
- [activityView stopAnimating];
+ [_activityView stopAnimating];
[UIView animateWithDuration:0.25 animations:^(void)
{
- buttonImageView.transform = CGAffineTransformIdentity;
- activityView.transform = CGAffineTransformIdentity;
+ _buttonImageView.transform = CGAffineTransformIdentity;
+ _activityView.transform = CGAffineTransformIdentity;
}];
}];
- state = (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? RMUserTrackingButtonStateHeading : RMUserTrackingButtonStateLocation);
+ _state = (_mapView.userTrackingMode == RMUserTrackingModeFollowWithHeading ? RMUserTrackingButtonStateHeading : RMUserTrackingButtonStateLocation);
}
}
}
View
2  MapView/Map/RouteMe.h
@@ -42,8 +42,6 @@
#import "RMFractalTileProjection.h"
#import "RMGenericMapSource.h"
#import "RMGlobalConstants.h"
-#import "RMMBTilesSource.h"
-#import "RMMapBoxSource.h"
#import "RMMapLayer.h"
#import "RMMapOverlayView.h"
#import "RMMapQuestOSMSource.h"
View
16 MapView/MapView.xcodeproj/project.pbxproj
@@ -95,14 +95,10 @@
DD2B375014CF814F008DE8CB /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = DD2B374C14CF814F008DE8CB /* FMDatabasePool.m */; };
DD2B375114CF814F008DE8CB /* FMDatabaseQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = DD2B374D14CF814F008DE8CB /* FMDatabaseQueue.h */; };
DD2B375214CF814F008DE8CB /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = DD2B374E14CF814F008DE8CB /* FMDatabaseQueue.m */; };
- DD2B375514CF8197008DE8CB /* RMMBTilesSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */; };
- DD2B375614CF8197008DE8CB /* RMMBTilesSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */; };
DD8CDB4A14E0507100B73EB9 /* RMMapQuestOSMSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */; };
DD8CDB4B14E0507100B73EB9 /* RMMapQuestOSMSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */; };
DD8FD7541559E4A40044D96F /* RMUserLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = DD8FD7521559E4A40044D96F /* RMUserLocation.h */; };
DD8FD7551559E4A40044D96F /* RMUserLocation.m in Sources */ = {isa = PBXBuildFile; fileRef = DD8FD7531559E4A40044D96F /* RMUserLocation.m */; };
- DD98B6FA14D76B930092882F /* RMMapBoxSource.h in Headers */ = {isa = PBXBuildFile; fileRef = DD98B6F814D76B930092882F /* RMMapBoxSource.h */; };
- DD98B6FB14D76B930092882F /* RMMapBoxSource.m in Sources */ = {isa = PBXBuildFile; fileRef = DD98B6F914D76B930092882F /* RMMapBoxSource.m */; };
DDA6B8BD155CAB67003DB5D8 /* RMUserTrackingBarButtonItem.h in Headers */ = {isa = PBXBuildFile; fileRef = DDA6B8BB155CAB67003DB5D8 /* RMUserTrackingBarButtonItem.h */; };
DDA6B8BE155CAB67003DB5D8 /* RMUserTrackingBarButtonItem.m in Sources */ = {isa = PBXBuildFile; fileRef = DDA6B8BC155CAB67003DB5D8 /* RMUserTrackingBarButtonItem.m */; };
/* End PBXBuildFile section */
@@ -227,8 +223,6 @@
DD2B374C14CF814F008DE8CB /* FMDatabasePool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabasePool.m; sourceTree = "<group>"; };
DD2B374D14CF814F008DE8CB /* FMDatabaseQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseQueue.h; sourceTree = "<group>"; };
DD2B374E14CF814F008DE8CB /* FMDatabaseQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseQueue.m; sourceTree = "<group>"; };
- DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMBTilesSource.h; sourceTree = "<group>"; };
- DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMBTilesSource.m; sourceTree = "<group>"; };
DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMapQuestOSMSource.h; sourceTree = "<group>"; };
DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMapQuestOSMSource.m; sourceTree = "<group>"; };
DD8FD7521559E4A40044D96F /* RMUserLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMUserLocation.h; sourceTree = "<group>"; };
@@ -239,8 +233,6 @@
DD8FD7661559EE120044D96F /* TrackingDot@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "TrackingDot@2x.png"; path = "Resources/TrackingDot@2x.png"; sourceTree = "<group>"; };
DD8FD7691559EE120044D96F /* TrackingDotHalo@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "TrackingDotHalo@2x.png"; path = "Resources/TrackingDotHalo@2x.png"; sourceTree = "<group>"; };
DD8FD76C1559EE120044D96F /* TrackingDotHalo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TrackingDotHalo.png; path = Resources/TrackingDotHalo.png; sourceTree = "<group>"; };
- DD98B6F814D76B930092882F /* RMMapBoxSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMapBoxSource.h; sourceTree = "<group>"; };
- DD98B6F914D76B930092882F /* RMMapBoxSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMapBoxSource.m; sourceTree = "<group>"; };
DDA6B8BB155CAB67003DB5D8 /* RMUserTrackingBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMUserTrackingBarButtonItem.h; sourceTree = "<group>"; };
DDA6B8BC155CAB67003DB5D8 /* RMUserTrackingBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMUserTrackingBarButtonItem.m; sourceTree = "<group>"; };
DDA6B8C0155CAB9A003DB5D8 /* TrackingLocation.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TrackingLocation.png; path = Resources/TrackingLocation.png; sourceTree = "<group>"; };
@@ -285,14 +277,10 @@
D1437B32122869E400888DAE /* RMDBMapSource.m */,
1607499314E120A100D535F5 /* RMGenericMapSource.h */,
1607499414E120A100D535F5 /* RMGenericMapSource.m */,
- DD98B6F814D76B930092882F /* RMMapBoxSource.h */,
- DD98B6F914D76B930092882F /* RMMapBoxSource.m */,
16FFF2C914E3DBF700A170EC /* RMMapQuestOpenAerialSource.h */,
16FFF2CA14E3DBF700A170EC /* RMMapQuestOpenAerialSource.m */,
DD8CDB4814E0507100B73EB9 /* RMMapQuestOSMSource.h */,
DD8CDB4914E0507100B73EB9 /* RMMapQuestOSMSource.m */,
- DD2B375314CF8197008DE8CB /* RMMBTilesSource.h */,
- DD2B375414CF8197008DE8CB /* RMMBTilesSource.m */,
1606C9FC13D86BA300547581 /* RMOpenCycleMapSource.h */,
1606C9FD13D86BA300547581 /* RMOpenCycleMapSource.m */,
16128CF3148D295300C23C0E /* RMOpenSeaMapSource.h */,
@@ -584,8 +572,6 @@
DD2B374914CF8041008DE8CB /* FMResultSet.h in Headers */,
DD2B374F14CF814F008DE8CB /* FMDatabasePool.h in Headers */,
DD2B375114CF814F008DE8CB /* FMDatabaseQueue.h in Headers */,
- DD2B375514CF8197008DE8CB /* RMMBTilesSource.h in Headers */,
- DD98B6FA14D76B930092882F /* RMMapBoxSource.h in Headers */,
DD8CDB4A14E0507100B73EB9 /* RMMapQuestOSMSource.h in Headers */,
1607499514E120A100D535F5 /* RMGenericMapSource.h in Headers */,
16FFF2CB14E3DBF700A170EC /* RMMapQuestOpenAerialSource.h in Headers */,
@@ -699,8 +685,6 @@
DD2B374A14CF8041008DE8CB /* FMResultSet.m in Sources */,
DD2B375014CF814F008DE8CB /* FMDatabasePool.m in Sources */,
DD2B375214CF814F008DE8CB /* FMDatabaseQueue.m in Sources */,
- DD2B375614CF8197008DE8CB /* RMMBTilesSource.m in Sources */,
- DD98B6FB14D76B930092882F /* RMMapBoxSource.m in Sources */,
DD8CDB4B14E0507100B73EB9 /* RMMapQuestOSMSource.m in Sources */,
1607499614E120A100D535F5 /* RMGenericMapSource.m in Sources */,
16FFF2CC14E3DBF700A170EC /* RMMapQuestOpenAerialSource.m in Sources */,
View
2  MapView/MapView_Prefix.pch
@@ -12,7 +12,7 @@
#endif
#if DEBUG
-#define RMLog(args...) NSLog(@"%@", [NSString stringWithFormat: args])
+#define RMLog(args...) NSLog(@"%@", [NSString stringWithFormat: args])
#define LogMethod() NSLog(@"logged method call: -[%@ %@] (line %d)", self, NSStringFromSelector(_cmd), __LINE__)
#define WarnDeprecated() NSLog(@"***** WARNING: deprecated method call: -[%@ %@] (line %d)", self, NSStringFromSelector(_cmd), __LINE__)
#else
View
4 MapView/UnitTesting/RouteMeTests.m
@@ -181,14 +181,14 @@ - (void)testMarkerCoordinatesFarWest
STAssertGreaterThan(columnSpacing, 0.0, @"this test requires positive columnSpacing");
RMMarkerManager *mangler = [[mapView contents] markerManager];
-
+
[[mapView contents] moveBy:CGSizeMake(-5.0, 0.0)];
#ifdef DEBUG
RMSphericalTrapezium screenLimitsDegrees = [[mapView contents] latitudeLongitudeBoundingBox];
RMLog(@"screen limits west: %4.1f east %4.1f", screenLimitsDegrees.southwest.longitude, screenLimitsDegrees.northeast.longitude);
RMLog(@"screen limits south: %4.1f north %4.1f", screenLimitsDegrees.southwest.latitude, screenLimitsDegrees.northeast.latitude);
#endif
-
+
for (j = 1; j < nColumns; j++) {
RMMarker *leftMarker = [testMarkers objectAtIndex:j - 1];
RMMarker *rightMarker = [testMarkers objectAtIndex:j];
Please sign in to comment.
Something went wrong with that request. Please try again.