Permalink
Browse files

Making it so the map defaults to a place specified in config. Current…

…ly centered on UW's quad, at a somewhat reasonable zoom level.
  • Loading branch information...
vegitron committed May 30, 2012
1 parent aff54f3 commit ff77728ccb6c1dc26f062708b06f1f47a0d0b784
@@ -50,6 +50,8 @@
C24C116A1536744B00109C30 /* Favorites.m in Sources */ = {isa = PBXBuildFile; fileRef = C24C11691536744B00109C30 /* Favorites.m */; };
C2516666153370CF002CEDB6 /* example_spotseeker.plist in Resources */ = {isa = PBXBuildFile; fileRef = C2516665153370CF002CEDB6 /* example_spotseeker.plist */; };
C25166691533713B002CEDB6 /* spotseeker.plist in Resources */ = {isa = PBXBuildFile; fileRef = C25166681533713B002CEDB6 /* spotseeker.plist */; };
+ C25D6F941576ACDC00A16A87 /* map_defaults.json in Resources */ = {isa = PBXBuildFile; fileRef = C25D6F931576ACDC00A16A87 /* map_defaults.json */; };
+ C25D6F971576AF7100A16A87 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C25D6F961576AF7100A16A87 /* CoreLocation.framework */; };
C26EAA23156EE32600632C78 /* SpotClusterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C26EAA22156EE32600632C78 /* SpotClusterViewController.m */; };
C277E87D1551FC7A0022FACD /* details_config.json in Resources */ = {isa = PBXBuildFile; fileRef = C277E87C1551FC7A0022FACD /* details_config.json */; };
C277E8801551FD930022FACD /* DisplayOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = C277E87F1551FD920022FACD /* DisplayOptions.m */; };
@@ -205,6 +207,8 @@
C24C11691536744B00109C30 /* Favorites.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Favorites.m; path = Models/Favorites.m; sourceTree = "<group>"; };
C2516665153370CF002CEDB6 /* example_spotseeker.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = example_spotseeker.plist; sourceTree = "<group>"; };
C25166681533713B002CEDB6 /* spotseeker.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = spotseeker.plist; sourceTree = "<group>"; };
+ C25D6F931576ACDC00A16A87 /* map_defaults.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = map_defaults.json; sourceTree = "<group>"; };
+ C25D6F961576AF7100A16A87 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
C26EAA21156EE32600632C78 /* SpotClusterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SpotClusterViewController.h; path = ViewControllers/SpotClusterViewController.h; sourceTree = "<group>"; };
C26EAA22156EE32600632C78 /* SpotClusterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SpotClusterViewController.m; path = ViewControllers/SpotClusterViewController.m; sourceTree = "<group>"; };
C277E87C1551FC7A0022FACD /* details_config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = details_config.json; sourceTree = "<group>"; };
@@ -294,6 +298,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ C25D6F971576AF7100A16A87 /* CoreLocation.framework in Frameworks */,
C2429A9D150AAC2B005A994A /* CFNetwork.framework in Frameworks */,
C2429A9B150AAC21005A994A /* SystemConfiguration.framework in Frameworks */,
C2429A99150AAC15005A994A /* MobileCoreServices.framework in Frameworks */,
@@ -523,6 +528,7 @@
C2FDB0D3150A802D00ED3A93 = {
isa = PBXGroup;
children = (
+ C25D6F961576AF7100A16A87 /* CoreLocation.framework */,
C2FDB0E8150A802D00ED3A93 /* SpotSeeker */,
C2FDB106150A802E00ED3A93 /* SpotSeekerTests */,
C2FDB0E1150A802D00ED3A93 /* Frameworks */,
@@ -589,6 +595,7 @@
C2516665153370CF002CEDB6 /* example_spotseeker.plist */,
C224FBED15361C2300CD4A79 /* filter_config.json */,
C277E87C1551FC7A0022FACD /* details_config.json */,
+ C25D6F931576ACDC00A16A87 /* map_defaults.json */,
);
name = "Supporting Files";
sourceTree = "<group>";
@@ -727,6 +734,7 @@
C2AFB7B9156C370100D19E7A /* 03.png in Resources */,
C2AFB7BA156C370100D19E7A /* 02.png in Resources */,
C2AFB7BB156C370100D19E7A /* 01.png in Resources */,
+ C25D6F941576ACDC00A16A87 /* map_defaults.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -18,6 +18,7 @@
//
#import <MapKit/MapKit.h>
+#import "SBJson.h"
#import "ViewController.h"
#import "Spot.h"
#import "SpotAnnotation.h"
@@ -128,13 +128,29 @@ -(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
+ if (userLocation.location == nil) {
+ NSData *data_source = [[NSData alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"map_defaults" ofType:@"json"]];
+
+ SBJsonParser *parser = [[SBJsonParser alloc] init];
+ NSDictionary *values = [parser objectWithData:data_source];
+
+ MKCoordinateRegion mapRegion;
+ mapRegion.center = CLLocationCoordinate2DMake([[values objectForKey:@"latitude"] doubleValue], [[values objectForKey:@"longitude"] doubleValue]);
+ mapRegion.span.latitudeDelta = [[values objectForKey:@"latitude_delta"] doubleValue];
+ mapRegion.span.longitudeDelta = [[values objectForKey:@"longitude_delta"] doubleValue];
+
+ [map_view setRegion:mapRegion animated: NO];
+ }
[self centerOnUserLocation];
}
#pragma mark -
-(void)centerOnUserLocation {
- MKCoordinateRegion mapRegion;
+ MKCoordinateRegion mapRegion;
+ if (map_view.userLocation.coordinate.latitude == 0.0 && map_view.userLocation.coordinate.longitude == 0.0) {
+ return;
+ }
mapRegion.center = map_view.userLocation.coordinate;
mapRegion.span.latitudeDelta = 0.005;
mapRegion.span.longitudeDelta = 0.005;
@@ -867,8 +867,8 @@ AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA
<simulatedScreenMetrics key="destination"/>
</simulatedMetricsContainer>
<inferredMetricsTieBreakers>
- <segue reference="2aF-sA-100"/>
- <segue reference="7BZ-SZ-G39"/>
- <segue reference="ehC-Lb-oxn"/>
+ <segue reference="3uu-G9-i3V"/>
+ <segue reference="rfQ-ts-oNK"/>
+ <segue reference="em9-ZW-DQ1"/>
</inferredMetricsTieBreakers>
</document>
@@ -0,0 +1,6 @@
+{
+ "longitude":-122.307208,
+ "latitude":47.657265,
+ "longitude_delta":0.003,
+ "latitude_delta":0.003
+}

0 comments on commit ff77728

Please sign in to comment.