Skip to content

Commit

Permalink
All the things, March 18
Browse files Browse the repository at this point in the history
  • Loading branch information
xirianlight committed Mar 18, 2013
1 parent 576bac9 commit 047a983
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 6 deletions.
18 changes: 18 additions & 0 deletions MappingMashupApp.xcodeproj/project.pbxproj
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
8335571616F6D27600DB17D5 /* YelpWebPageBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = 8335571516F6D27600DB17D5 /* YelpWebPageBrowser.m */; };
8335571916F754C800DB17D5 /* xmark.png in Resources */ = {isa = PBXBuildFile; fileRef = 8335571816F754C800DB17D5 /* xmark.png */; };
8335571D16F7579600DB17D5 /* wifiIcon2@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8335571C16F7579600DB17D5 /* wifiIcon2@2x.png */; };
8335571F16F759B600DB17D5 /* wifiIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8335571E16F759B600DB17D5 /* wifiIcon@2x.png */; };
8F372B0416F244C800302B80 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F372B0316F244C800302B80 /* UIKit.framework */; };
8F372B0616F244C800302B80 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F372B0516F244C800302B80 /* Foundation.framework */; };
8F372B0816F244C800302B80 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8F372B0716F244C800302B80 /* CoreGraphics.framework */; };
Expand Down Expand Up @@ -58,6 +62,11 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
8335571416F6D27600DB17D5 /* YelpWebPageBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YelpWebPageBrowser.h; sourceTree = "<group>"; };
8335571516F6D27600DB17D5 /* YelpWebPageBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YelpWebPageBrowser.m; sourceTree = "<group>"; };
8335571816F754C800DB17D5 /* xmark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = xmark.png; sourceTree = "<group>"; };
8335571C16F7579600DB17D5 /* wifiIcon2@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "wifiIcon2@2x.png"; sourceTree = "<group>"; };
8335571E16F759B600DB17D5 /* wifiIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "wifiIcon@2x.png"; sourceTree = "<group>"; };
8F372B0016F244C800302B80 /* MappingMashupApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MappingMashupApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
8F372B0316F244C800302B80 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8F372B0516F244C800302B80 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -120,6 +129,9 @@
8F372AF716F244C800302B80 = {
isa = PBXGroup;
children = (
8335571E16F759B600DB17D5 /* wifiIcon@2x.png */,
8335571C16F7579600DB17D5 /* wifiIcon2@2x.png */,
8335571816F754C800DB17D5 /* xmark.png */,
B40B477716F691CE006BD4CE /* Model.xcdatamodeld */,
8F372B0916F244C800302B80 /* MappingMashupApp */,
8F372B0216F244C800302B80 /* Frameworks */,
Expand Down Expand Up @@ -225,6 +237,8 @@
8F372B5E16F269B100302B80 /* View Controllers */ = {
isa = PBXGroup;
children = (
8335571416F6D27600DB17D5 /* YelpWebPageBrowser.h */,
8335571516F6D27600DB17D5 /* YelpWebPageBrowser.m */,
8F372B1E16F244C800302B80 /* YelpMapViewController.h */,
8F372B1F16F244C800302B80 /* YelpMapViewController.m */,
);
Expand Down Expand Up @@ -330,6 +344,9 @@
8F372B1816F244C800302B80 /* Default@2x.png in Resources */,
8F372B1A16F244C800302B80 /* Default-568h@2x.png in Resources */,
8F372B1D16F244C800302B80 /* MainStoryboard.storyboard in Resources */,
8335571916F754C800DB17D5 /* xmark.png in Resources */,
8335571D16F7579600DB17D5 /* wifiIcon2@2x.png in Resources */,
8335571F16F759B600DB17D5 /* wifiIcon@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -351,6 +368,7 @@
B425500916F6B158005CCC9E /* Venue.m in Sources */,
B425500C16F6B1C2005CCC9E /* Business.m in Sources */,
B425500F16F6B1C2005CCC9E /* Photo.m in Sources */,
8335571616F6D27600DB17D5 /* YelpWebPageBrowser.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion MappingMashupApp/APIManager.m
Expand Up @@ -24,7 +24,7 @@ - (APIManager*)initWithFlickrSearch:(NSString*)search andLocation:(LocationManag
//api method call for yelp
- (APIManager*)initWithYelpSearch:(NSString*)search andLocation:(LocationManager*)userLocation
{
apiCall = [NSString stringWithFormat:@"http://api.yelp.com/business_review_search?term=%@&lat=%f&long=%f&radius=10&limit=5&ywsid=SHvJpobPrBabhrCyJ8FMag",search, userLocation.coordinate.latitude, userLocation.coordinate.longitude];
apiCall = [NSString stringWithFormat:@"http://api.yelp.com/business_review_search?term=%@&lat=%f&long=%f&radius=1&limit=20&ywsid=z8HZy2Hb2axZox05xfTW9w",search, userLocation.coordinate.latitude, userLocation.coordinate.longitude];
return self;
}

Expand Down
1 change: 1 addition & 0 deletions MappingMashupApp/Annotation.h
Expand Up @@ -14,6 +14,7 @@
@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSString *subtitle;
@property (assign, nonatomic) CLLocationCoordinate2D coordinate;
@property (strong, nonatomic) NSString *yelpPageURL;

- initWithPosition:(CLLocationCoordinate2D *)coordinates;

Expand Down
2 changes: 1 addition & 1 deletion MappingMashupApp/Annotation.m
Expand Up @@ -9,7 +9,7 @@
#import "Annotation.h"

@implementation Annotation
@synthesize coordinate,title,subtitle;
@synthesize coordinate,title,subtitle, yelpPageURL;

- initWithPosition:(CLLocationCoordinate2D *)coordinates
{
Expand Down
2 changes: 1 addition & 1 deletion MappingMashupApp/YelpMapViewController.h
Expand Up @@ -10,7 +10,7 @@
#import "DataSourceDelegate.h"
#import <CoreData/CoreData.h>

@interface YelpMapViewController : UIViewController <DataSourceDelegate>
@interface YelpMapViewController : UIViewController <DataSourceDelegate, MKMapViewDelegate>

@property (strong, nonatomic) NSMutableArray *returnedArray;
@property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
Expand Down
95 changes: 93 additions & 2 deletions MappingMashupApp/YelpMapViewController.m
Expand Up @@ -14,6 +14,7 @@
#import "APIManager.h"
#import "LocationManager.h"
#import "AppDelegate.h"
#import "YelpWebPageBrowser.h"


@interface YelpMapViewController ()
Expand All @@ -22,6 +23,7 @@ @interface YelpMapViewController ()
__weak IBOutlet MKMapView *myMapView;
NSMutableArray *yelpData;
LocationManager *mobileMakersLocation;
Annotation * selectedAnnotation;
}
@end

Expand All @@ -38,7 +40,34 @@ - (void)viewDidLoad

mobileMakersLocation = [[LocationManager alloc] init];

yelpProcess = [[APIManager alloc]initWithYelpSearch:@"food" andLocation:mobileMakersLocation];
//Ross' changes 3.17.13
CLLocationCoordinate2D mmCoordinate =
{
.latitude = 41.894032f,
.longitude = -87.634742f
};

MKCoordinateSpan defaultSpan =
{
.latitudeDelta = 0.02f,
.longitudeDelta = 0.02f
};

MKCoordinateRegion myRegion = {mmCoordinate, defaultSpan};
MKUserLocation *myCurrentLocation = [[Annotation alloc] init];
// myCurrentLocation.annotationType = @"currentLocation";
// myCurrentLocation.title = @"You are here.";
// myCurrentLocation.coordinate = mmCoordinate;

[myMapView addAnnotation:myCurrentLocation];


[myMapView setRegion:myRegion animated:YES];

//End ross' changes


yelpProcess = [[APIManager alloc]initWithYelpSearch:@"free%20wifi" andLocation:mobileMakersLocation];

yelpProcess.delegate = self;

Expand All @@ -64,6 +93,8 @@ - (NSMutableArray *)createPlacesArray:(NSArray *)placesData
Venue *place = [[Venue alloc] init];
place.name = [placeDictionary valueForKey:@"name"];
place.location = placeLocation;
place.yelpURL= [placeDictionary valueForKey:@"url"];

[returnedArray addObject:place];
}
return returnedArray;
Expand All @@ -80,13 +111,14 @@ -(void)addPinsToMap

MKCoordinateRegion myRegion = {mobileMakersLocation.coordinate, span};
//set region to mapview
[myMapView setRegion:myRegion];
[myMapView setRegion:myRegion animated:YES];


for (int i = 0; i < returnedArray.count; i++)
{
CLLocation *locationOfPlace = [[returnedArray objectAtIndex:i] location];
NSString *nameOfPlace = [[returnedArray objectAtIndex:i] name];
// NSString *addressOfPlace = [[returnedArray objectAtIndex:i] addres];

//coordinate make
CLLocationCoordinate2D placeCoordinate;
Expand All @@ -96,13 +128,72 @@ -(void)addPinsToMap
//annotation make
Annotation *myAnnotation = [[Annotation alloc] initWithPosition:&placeCoordinate];
myAnnotation.title = nameOfPlace;
myAnnotation.subtitle = @"Demo subtitle";

NSLog(@"%@", returnedArray);
//Add code here to capture yelp page URL
NSString *yelpURLString = [[returnedArray objectAtIndex:i] valueForKey:@"yelpURL"];
NSLog(@"%@", yelpURLString);
myAnnotation.yelpPageURL = yelpURLString;

//add to map
[myMapView addAnnotation:myAnnotation];
}
}

-(MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{

UIButton *detailButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"myAnnotation"];

if (annotationView == nil) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"myAnnotation"];
}

// [detailButton addTarget:self
// action:@selector(goToYelpPage)
// forControlEvents:UIControlEventTouchUpInside];
annotationView.canShowCallout = YES;
annotationView.image = [UIImage imageNamed:@"wifiIcon.png"];
annotationView.rightCalloutAccessoryView = detailButton;

return annotationView;
}

//User taps on disclosure button to see more Yelp data.
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
NSLog(@"This is the method we want!");
// [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"m.yelp.com"]];
[self performSegueWithIdentifier:@"toYelpWebPage" sender:nil];


}

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
YelpWebPageBrowser * ywpb = [segue destinationViewController];
ywpb.yelpURLString = selectedAnnotation.yelpPageURL;
}

//Look at this
//This method gets called when you select an annotation
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
selectedAnnotation = view.annotation;

}



//Method for unwind action
-(IBAction) backToYelpMapView: (UIStoryboardSegue *)segue
{
//Any additional actions to be performed during unwind
}

# pragma mark -- End of document

- (void)didReceiveMemoryWarning
{
Expand Down
15 changes: 15 additions & 0 deletions MappingMashupApp/YelpWebPageBrowser.h
@@ -0,0 +1,15 @@
//
// YelpWebPageBrowser.h
// MappingMashupApp
//
// Created by Ross Matsuda on 3/17/13.
// Copyright (c) 2013 The Peanut Gallery. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface YelpWebPageBrowser : UIViewController <UIWebViewDelegate>

@property (strong, nonatomic) NSString *yelpURLString;

@end
46 changes: 46 additions & 0 deletions MappingMashupApp/YelpWebPageBrowser.m
@@ -0,0 +1,46 @@
//
// YelpWebPageBrowser.m
// MappingMashupApp
//
// Created by Ross Matsuda on 3/17/13.
// Copyright (c) 2013 The Peanut Gallery. All rights reserved.
//

#import "YelpWebPageBrowser.h"

@interface YelpWebPageBrowser ()
{

__weak IBOutlet UIWebView *webView;
}

@end

@implementation YelpWebPageBrowser
@synthesize yelpURLString;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];

NSString *homePage = [NSString stringWithFormat:@"%@", yelpURLString];
NSURL * url = [NSURL URLWithString:homePage];
NSURLRequest * urlRequest = [NSURLRequest requestWithURL:url];
[webView loadRequest: urlRequest];}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end
58 changes: 57 additions & 1 deletion MappingMashupApp/en.lproj/MainStoryboard.storyboard
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12C60" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="2">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12D78" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="2">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/>
</dependencies>
Expand All @@ -14,25 +14,81 @@
<subviews>
<mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" id="fse-RH-zXz">
<rect key="frame" x="0.0" y="0.0" width="320" height="548"/>
<connections>
<outlet property="delegate" destination="2" id="xSJ-gt-oCr"/>
</connections>
</mapView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<connections>
<outlet property="myMapView" destination="fse-RH-zXz" id="kM2-Uz-1iT"/>
<segue destination="qVE-kj-ncM" kind="modal" identifier="toYelpWebPage" id="grn-P3-leO"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4" sceneMemberID="firstResponder"/>
</objects>
</scene>
<!--Yelp Web Page Browser-->
<scene sceneID="5PQ-wp-x5Z">
<objects>
<viewController id="qVE-kj-ncM" customClass="YelpWebPageBrowser" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="wEa-dC-5Et">
<rect key="frame" x="0.0" y="20" width="320" height="548"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<webView contentMode="scaleToFill" id="tBs-TS-l6k">
<rect key="frame" x="0.0" y="0.0" width="320" height="548"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
<connections>
<outlet property="delegate" destination="qVE-kj-ncM" id="c7l-wu-QlU"/>
</connections>
</webView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="v2A-LT-eS2">
<rect key="frame" x="282" y="508" width="32" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<state key="normal" title="Back" image="xmark.png">
<color key="titleColor" red="0.19607843459999999" green="0.30980393290000002" blue="0.52156865600000002" alpha="1" colorSpace="calibratedRGB"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="highlighted">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<segue destination="5YE-ke-7F9" kind="unwind" unwindAction="backToYelpMapView:" id="feb-hB-Kev"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" cocoaTouchSystemColor="scrollViewTexturedBackgroundColor"/>
</view>
<connections>
<outlet property="webView" destination="tBs-TS-l6k" id="kQ5-DS-WTP"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="UfP-Tc-Lc4" userLabel="First Responder" sceneMemberID="firstResponder"/>
<exit id="5YE-ke-7F9" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="711" y="138"/>
</scene>
</scenes>
<resources>
<image name="xmark.png" width="64" height="64"/>
</resources>
<classes>
<class className="YelpMapViewController" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/YelpMapViewController.h"/>
<relationships>
<relationship kind="outlet" name="myMapView" candidateClass="MKMapView"/>
</relationships>
</class>
<class className="YelpWebPageBrowser" superclassName="UIViewController">
<source key="sourceIdentifier" type="project" relativePath="./Classes/YelpWebPageBrowser.h"/>
<relationships>
<relationship kind="outlet" name="webView" candidateClass="UIWebView"/>
</relationships>
</class>
</classes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
Expand Down

0 comments on commit 047a983

Please sign in to comment.