Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implemented almost Google Maps API wrappers.

  • Loading branch information...
commit c9d15f84609d9563c389e7321b70f70ef16db3e5 1 parent 2da8058
@kishikawakatsumi authored
View
1  Classes/MapDirectionsAppDelegate.h
@@ -7,7 +7,6 @@
//
@interface MapDirectionsAppDelegate : NSObject <UIApplicationDelegate> {
-
UIWindow *window;
UINavigationController *navigationController;
}
View
9 Classes/MapDirectionsAppDelegate.m
@@ -18,18 +18,11 @@ @implementation MapDirectionsAppDelegate
#pragma mark -
#pragma mark Application lifecycle
-- (void)applicationDidFinishLaunching:(UIApplication *)application {
-
- // Override point for customization after app launch
-
+- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
-- (void)applicationWillTerminate:(UIApplication *)application {
- // Save data if appropriate
-}
-
#pragma mark -
#pragma mark Memory management
View
2  Classes/MapDirectionsViewController.h
@@ -18,10 +18,12 @@
UICGDirections *diretions;
NSString *startPoint;
NSString *endPoint;
+ NSArray *wayPoints;
}
@property (nonatomic, retain) NSString *startPoint;
@property (nonatomic, retain) NSString *endPoint;
+@property (nonatomic, retain) NSArray *wayPoints;
- (void)update;
View
126 Classes/MapDirectionsViewController.m
@@ -10,11 +10,13 @@
#import "UICRouteOverlayMapView.h"
#import "UICGDirections.h"
#import "UICRouteAnnotation.h"
+#import "RouteListViewController.h"
@implementation MapDirectionsViewController
@synthesize startPoint;
@synthesize endPoint;
+@synthesize wayPoints;
- (void)dealloc {
[routeOverlayView release];
@@ -24,31 +26,34 @@ - (void)dealloc {
}
- (void)loadView {
- UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 416.0f)];
+ UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 372.0f)];
self.view = contentView;
[contentView release];
+
routeMapView = [[MKMapView alloc] initWithFrame:contentView.frame];
routeMapView.delegate = self;
+ routeMapView.showsUserLocation = YES;
[contentView addSubview:routeMapView];
[routeMapView release];
routeOverlayView = [[UICRouteOverlayMapView alloc] initWithMapView:routeMapView];
+ UIBarButtonItem *space = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
+ UIBarButtonItem *currentLocationButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"reticle.png"] style:UIBarButtonItemStylePlain target:self action:@selector(moveToCurrentLocation:)] autorelease];
+ UIBarButtonItem *mapPinButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"map_pin.png"] style:UIBarButtonItemStylePlain target:self action:@selector(addPinAnnotation:)] autorelease];
+ UIBarButtonItem *routesButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"list.png"] style:UIBarButtonItemStylePlain target:self action:@selector(showRouteListView:)] autorelease];
+ self.toolbarItems = [NSArray arrayWithObjects:currentLocationButton, space, mapPinButton, routesButton, nil];
+ [self.navigationController setToolbarHidden:NO animated:NO];
+
diretions = [UICGDirections sharedDirections];
diretions.delegate = self;
}
- (void)viewDidLoad {
[super viewDidLoad];
-}
-
-- (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self update];
-}
-
-- (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
+ if (diretions.isInitialized) {
+ [self update];
+ }
}
- (void)didReceiveMemoryWarning {
@@ -57,35 +62,87 @@ - (void)didReceiveMemoryWarning {
- (void)update {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
- [diretions loadWithStartPoint:startPoint endPoint:endPoint options:nil];
+
+ UICGDirectionsOptions *options = [[[UICGDirectionsOptions alloc] init] autorelease];
+ if ([wayPoints count] > 0) {
+ NSArray *routePoints = [NSArray arrayWithObject:startPoint];
+ routePoints = [routePoints arrayByAddingObjectsFromArray:wayPoints];
+ routePoints = [routePoints arrayByAddingObject:endPoint];
+ [diretions loadFromWaypoints:routePoints options:options];
+ } else {
+ [diretions loadWithStartPoint:startPoint endPoint:endPoint options:options];
+ }
+}
+
+- (void)moveToCurrentLocation:(id)sender {
+ [routeMapView setCenterCoordinate:[routeMapView.userLocation coordinate] animated:YES];
+}
+
+- (void)addPinAnnotation:(id)sender {
+ UICRouteAnnotation *pinAnnotation = [[[UICRouteAnnotation alloc] initWithCoordinate:[routeMapView centerCoordinate]
+ title:nil
+ annotationType:UICRouteAnnotationTypeWayPoint] autorelease];
+ [routeMapView addAnnotation:pinAnnotation];
+}
+
+- (void)showRouteListView:(id)sender {
+ RouteListViewController *controller = [[RouteListViewController alloc] initWithStyle:UITableViewStyleGrouped];
+ controller.routes = diretions.routes;
+ UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:controller];
+ [self presentModalViewController:navigationController animated:YES];
+ [controller release];
+ [navigationController release];
}
+#pragma mark <UICGDirectionsDelegate> Methods
+
- (void)directionsDidFinishInitialize:(UICGDirections *)directions {
[self update];
}
+- (void)directions:(UICGDirections *)directions didFailInitializeWithError:(NSError *)error {
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
+
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Map Directions" message:[error localizedFailureReason] delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
+ [alertView show];
+ [alertView release];
+}
+
- (void)directionsDidUpdateDirections:(UICGDirections *)directions {
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
+
+ // Overlay polylines
UICGPolyline *polyline = [directions polyline];
NSArray *routePoints = [polyline routePoints];
[routeOverlayView setRoutes:routePoints];
+ // Add annotations
UICRouteAnnotation *startAnnotation = [[[UICRouteAnnotation alloc] initWithCoordinate:[[routePoints objectAtIndex:0] coordinate]
title:startPoint
annotationType:UICRouteAnnotationTypeStart] autorelease];
-
- [routeMapView addAnnotation:startAnnotation];
-
UICRouteAnnotation *endAnnotation = [[[UICRouteAnnotation alloc] initWithCoordinate:[[routePoints lastObject] coordinate]
title:endPoint
annotationType:UICRouteAnnotationTypeEnd] autorelease];
- [routeMapView addAnnotation:endAnnotation];
-
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
+ if ([wayPoints count] > 0) {
+ NSInteger numberOfRoutes = [directions numberOfRoutes];
+ for (NSInteger index = 0; index < numberOfRoutes; index++) {
+ UICGRoute *route = [directions routeAtIndex:index];
+ CLLocation *location = [route endLocation];
+ UICRouteAnnotation *annotation = [[[UICRouteAnnotation alloc] initWithCoordinate:[location coordinate]
+ title:[[route endGeocode] objectForKey:@"address"]
+ annotationType:UICRouteAnnotationTypeWayPoint] autorelease];
+ [routeMapView addAnnotation:annotation];
+ }
+ }
+
+ [routeMapView addAnnotations:[NSArray arrayWithObjects:startAnnotation, endAnnotation, nil]];
}
- (void)directions:(UICGDirections *)directions didFailWithMessage:(NSString *)message {
- NSLog(@"%@", message);
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Map Directions" message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
+ [alertView show];
+ [alertView release];
}
#pragma mark <MKMapViewDelegate> Methods
@@ -99,19 +156,30 @@ - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
[routeOverlayView setNeedsDisplay];
}
-- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
- static NSString *identifier = @"Annotation";
- MKPinAnnotationView *pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
+- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
+ static NSString *identifier = @"RoutePinAnnotation";
- if(!pinAnnotation) {
- pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease];
+ if ([annotation isKindOfClass:[UICRouteAnnotation class]]) {
+ MKPinAnnotationView *pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
+ if(!pinAnnotation) {
+ pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier] autorelease];
+ }
+
+ if ([(UICRouteAnnotation *)annotation annotationType] == UICRouteAnnotationTypeStart) {
+ pinAnnotation.pinColor = MKPinAnnotationColorGreen;
+ } else if ([(UICRouteAnnotation *)annotation annotationType] == UICRouteAnnotationTypeEnd) {
+ pinAnnotation.pinColor = MKPinAnnotationColorRed;
+ } else {
+ pinAnnotation.pinColor = MKPinAnnotationColorPurple;
+ }
+
+ pinAnnotation.animatesDrop = YES;
+ pinAnnotation.enabled = YES;
+ pinAnnotation.canShowCallout = YES;
+ return pinAnnotation;
+ } else {
+ return [routeMapView viewForAnnotation:routeMapView.userLocation];
}
-
- pinAnnotation.pinColor = [(UICRouteAnnotation *)annotation annotationType] == UICRouteAnnotationTypeStart ? MKPinAnnotationColorGreen : MKPinAnnotationColorRed;
- pinAnnotation.enabled = YES;
- pinAnnotation.canShowCallout = YES;
-
- return pinAnnotation;
}
@end
View
1  Classes/RootViewController.h
@@ -9,6 +9,7 @@
@interface RootViewController : UITableViewController<UITextFieldDelegate> {
UITextField *startField;
UITextField *endField;
+ NSMutableArray *wayPointFields;
UISegmentedControl *travelModeSegment;
}
View
108 Classes/RootViewController.m
@@ -17,32 +17,20 @@ - (void)dealloc {
- (void)viewDidLoad {
[super viewDidLoad];
-}
-
-- (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-}
-
-- (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
-}
-
-- (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
-}
-
-- (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
+
+ wayPointFields = [[NSMutableArray alloc] init];
+
+ UIBarButtonItem *space = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
+ UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"add.png"] style:UIBarButtonItemStylePlain target:self action:@selector(addRow:)] autorelease];
+ UIBarButtonItem *removePinButton = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"remove.png"] style:UIBarButtonItemStylePlain target:self action:@selector(removeRow:)] autorelease];
+ self.toolbarItems = [NSArray arrayWithObjects:space, addButton, removePinButton, nil];
+ [self.navigationController setToolbarHidden:NO animated:NO];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-- (void)viewDidUnload {
-
-}
-
- (void)done:(id)sender {
if ([startField canResignFirstResponder]) {
[startField resignFirstResponder];
@@ -53,6 +41,19 @@ - (void)done:(id)sender {
[self.navigationItem setRightBarButtonItem:nil animated:YES];
}
+- (void)addRow:(id)sender {
+ [wayPointFields addObject:[[[UITextField alloc] initWithFrame:CGRectMake(66.0, 0.0, 236.0, 44.0)] autorelease]];
+ [self.tableView reloadData];
+}
+
+- (void)removeRow:(id)sender {
+ if ([wayPointFields count] <= 0) {
+ return;
+ }
+ [wayPointFields removeLastObject];
+ [self.tableView reloadData];
+}
+
#pragma mark UITextFieldDelegate Methods
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
@@ -82,7 +83,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0) {
- return 2;
+ return 2 + [wayPointFields count];
} else if (section == 1) {
return 1;
} else {
@@ -102,11 +103,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell%d%d", indexPath.section, indexPath.row];
-
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
- }
+ UITableViewCell *cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if (indexPath.section == 0 && indexPath.row == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
@@ -140,10 +137,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[inputField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[inputField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
- [inputField setText:[NSString stringWithUTF8String:"新宿西口"]];
+ [inputField setText:[NSString stringWithUTF8String:"セルリアンタワー"]];
startField = inputField;
- } else if (indexPath.section == 0 && indexPath.row == 1) {
+ } else if (indexPath.section == 0 && indexPath.row == 1 + [wayPointFields count]) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -178,6 +175,36 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[inputField setText:[NSString stringWithUTF8String:"東京ディズニーランド"]];
endField = inputField;
+ } else if (indexPath.section == 0) {
+ cell.selectionStyle = UITableViewCellSelectionStyleNone;
+ cell.accessoryType = UITableViewCellAccessoryNone;
+
+ UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(20.0f, 13.0f, 40.0f, 20.0f)];
+ [cell addSubview:textLabel];
+ [textLabel release];
+ textLabel.text = NSLocalizedString(@"via:", nil);
+ textLabel.font = [UIFont boldSystemFontOfSize:14.0f];
+ textLabel.textAlignment = UITextAlignmentRight;
+ textLabel.textColor = [UIColor lightGrayColor];
+
+ UITextField *inputField = [wayPointFields objectAtIndex:indexPath.row - 1];
+ inputField.delegate = self;
+ [cell addSubview:inputField];
+
+ [inputField setBorderStyle:UITextBorderStyleNone];
+ [inputField setAdjustsFontSizeToFitWidth:NO];
+ [inputField setClearButtonMode:UITextFieldViewModeWhileEditing];
+ [inputField setClearsOnBeginEditing:NO];
+ [inputField setPlaceholder:nil];
+ [inputField setAutocapitalizationType:UITextAutocapitalizationTypeNone];
+ [inputField setAutocorrectionType:UITextAutocorrectionTypeNo];
+ [inputField setEnablesReturnKeyAutomatically:YES];
+ [inputField setKeyboardType:UIKeyboardTypeDefault];
+ [inputField setReturnKeyType:UIReturnKeyDone];
+ [inputField setEnablesReturnKeyAutomatically:YES];
+
+ [inputField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
+ [inputField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
} else if (indexPath.section == 1 && indexPath.row == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -187,7 +214,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
NSLocalizedString(@"Train", nil),
NSLocalizedString(@"Walking", nil), nil]];
[travelModeSegment setFrame:CGRectMake(9.0f, 0.0f, 302.0f, 45.0f)];
- [travelModeSegment setSelectedSegmentIndex:0];
+ travelModeSegment.selectedSegmentIndex = 0;
[cell addSubview:travelModeSegment];
[travelModeSegment release];
} else {
@@ -195,19 +222,26 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
cell.accessoryType = UITableViewCellAccessoryNone;
cell.textLabel.text = NSLocalizedString(@"Search", nil);
cell.textLabel.textAlignment = UITextAlignmentCenter;
- cell.textLabel.textColor = [UIColor blueColor];
+ cell.textLabel.textColor = [UIColor colorWithRed:0.20 green:0.30 blue:0.49 alpha:1.0];
}
-
+
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- MapDirectionsViewController *controller = [[MapDirectionsViewController alloc] init];
- controller.startPoint = startField.text;
- controller.endPoint = endField.text;
- [self.navigationController pushViewController:controller animated:YES];
- [controller release];
- [tableView deselectRowAtIndexPath:indexPath animated:YES];
+ if (indexPath.section == 2 && indexPath.row == 0) {
+ MapDirectionsViewController *controller = [[MapDirectionsViewController alloc] init];
+ controller.startPoint = startField.text;
+ controller.endPoint = endField.text;
+ NSMutableArray *wayPoints = [NSMutableArray arrayWithCapacity:[wayPointFields count]];
+ for (UITextField *pointField in wayPointFields) {
+ [wayPoints addObject:pointField.text];
+ }
+ controller.wayPoints = wayPoints;
+ [self.navigationController pushViewController:controller animated:YES];
+ [controller release];
+ [tableView deselectRowAtIndexPath:indexPath animated:YES];
+ }
}
@end
View
17 Classes/RouteListViewController.h
@@ -0,0 +1,17 @@
+//
+// RouteListViewController.h
+// MapDirections
+//
+// Created by KISHIKAWA Katsumi on 09/08/12.
+// Copyright 2009 KISHIKAWA Katsumi. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface RouteListViewController : UITableViewController {
+ NSArray *routes;
+}
+
+@property (nonatomic, retain) NSArray *routes;
+
+@end
View
93 Classes/RouteListViewController.m
@@ -0,0 +1,93 @@
+//
+// RouteListViewController.m
+// MapDirections
+//
+// Created by KISHIKAWA Katsumi on 09/08/12.
+// Copyright 2009 KISHIKAWA Katsumi. All rights reserved.
+//
+
+#import "RouteListViewController.h"
+#import "UICGRoute.h"
+#import "UICGStep.h"
+
+@interface UITextView(HTML)
+- (void)setContentToHTMLString:(id)fp8;
+@end
+
+@implementation RouteListViewController
+
+@synthesize routes;
+
+- (void)dealloc {
+ [routes release];
+ [super dealloc];
+}
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
+ target:self
+ action:@selector(dismiss:)] autorelease];
+ self.title = NSLocalizedString(@"Routes", nil);
+ self.tableView.rowHeight = 60.0f;
+}
+
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+}
+
+- (void)dismiss:(id)sender {
+ [self dismissModalViewControllerAnimated:YES];
+}
+
+#pragma mark Table view methods
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
+ return [routes count];
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+ UICGRoute *route = [routes objectAtIndex:section];
+ return [route numerOfSteps];
+}
+
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
+ UICGRoute *route = [routes objectAtIndex:section];
+ return [route.summaryHtml stringByReplacingOccurrencesOfString:@"&nbsp;" withString:@" "];
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+ static NSString *CellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20.0f, 2.0f, 280.0f, 56.0f)];
+ textView.editable = NO;
+ textView.scrollEnabled = NO;
+ textView.opaque = YES;
+ textView.backgroundColor = [UIColor whiteColor];
+ textView.tag = 1;
+ [cell addSubview:textView];
+
+ cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
+ }
+
+ UICGRoute *route = [routes objectAtIndex:indexPath.section];
+ UICGStep *step = [route stepAtIndex:indexPath.row];
+
+ UITextView *textView = (UITextView *)[cell viewWithTag:1];
+ [textView setContentToHTMLString:step.descriptionHtml];
+
+ return cell;
+}
+
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+ // Navigation logic may go here. Create and push another view controller.
+ // AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
+ // [self.navigationController pushViewController:anotherViewController];
+ // [anotherViewController release];
+}
+
+@end
View
15 Classes/UICGClientGeocoder.h
@@ -0,0 +1,15 @@
+//
+// UICGClientGeocoder.h
+// MapDirections
+//
+// Created by KISHIKAWA Katsumi on 09/08/12.
+// Copyright 2009 KISHIKAWA Katsumi. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface UICGClientGeocoder : NSObject {
+
+}
+
+@end
View
13 Classes/UICGClientGeocoder.m
@@ -0,0 +1,13 @@
+//
+// UICGClientGeocoder.m
+// MapDirections
+//
+// Created by KISHIKAWA Katsumi on 09/08/12.
+// Copyright 2009 KISHIKAWA Katsumi. All rights reserved.
+//
+
+#import "UICGClientGeocoder.h"
+
+@implementation UICGClientGeocoder
+
+@end
View
14 Classes/UICGDirections.h
@@ -17,6 +17,7 @@
@protocol UICGDirectionsDelegate<NSObject>
@optional
- (void)directionsDidFinishInitialize:(UICGDirections *)directions;
+- (void)directions:(UICGDirections *)directions didFailInitializeWithError:(NSError *)error;
- (void)directionsDidUpdateDirections:(UICGDirections *)directions;
- (void)directions:(UICGDirections *)directions didFailWithMessage:(NSString *)message;
@end
@@ -24,29 +25,34 @@
@interface UICGDirections : NSObject<UIWebViewDelegate> {
id<UICGDirectionsDelegate> delegate;
UICGoogleMapsAPI *googleMapsAPI;
+ NSArray *routes;
+ NSArray *geocodes;
UICGPolyline *polyline;
NSDictionary *distance;
NSDictionary *duration;
+ NSDictionary *status;
+ BOOL isInitialized;
}
@property (nonatomic, assign) id<UICGDirectionsDelegate> delegate;
+@property (nonatomic, retain) NSArray *routes;
+@property (nonatomic, retain) NSArray *geocodes;
@property (nonatomic, retain) UICGPolyline *polyline;
@property (nonatomic, retain) NSDictionary *distance;
@property (nonatomic, retain) NSDictionary *duration;
+@property (nonatomic, retain) NSDictionary *status;
+@property (nonatomic, readonly) BOOL isInitialized;
+ (UICGDirections *)sharedDirections;
- (id)init;
+- (void)makeAvailable;
- (void)loadWithQuery:(NSString *)query options:(UICGDirectionsOptions *)options;
- (void)loadWithStartPoint:(NSString *)startPoint endPoint:(NSString *)endPoint options:(UICGDirectionsOptions *)options;
- (void)loadFromWaypoints:(NSArray *)waypoints options:(UICGDirectionsOptions *)options;
- (void)clear;
-- (NSDictionary *)status;
- (NSInteger)numberOfRoutes;
- (UICGRoute *)routeAtIndex:(NSInteger)index;
- (NSInteger)numberOfGeocodes;
- (NSDictionary *)geocodeAtIndex:(NSInteger)index;
-- (NSDictionary *)distance;
-- (NSDictionary *)duration;
-- (UICGPolyline *)polyline;
@end
View
54 Classes/UICGDirections.m
@@ -7,16 +7,21 @@
//
#import "UICGDirections.h"
+#import "UICGRoute.h"
#import "JSON.h"
static UICGDirections *sharedDirections;
@implementation UICGDirections
+@synthesize routes;
+@synthesize geocodes;
@synthesize delegate;
@synthesize polyline;
@synthesize distance;
@synthesize duration;
+@synthesize status;
+@synthesize isInitialized;
+ (UICGDirections *)sharedDirections {
if (!sharedDirections) {
@@ -36,15 +41,31 @@ - (id)init {
- (void)dealloc {
[googleMapsAPI release];
+ [routes release];
+ [geocodes release];
+ [polyline release];
+ [distance release];
+ [duration release];
+ [status release];
[super dealloc];
}
+- (void)makeAvailable {
+ [googleMapsAPI makeAvailable];
+}
+
- (void)goolgeMapsAPI:(UICGoogleMapsAPI *)goolgeMapsAPI didGetObject:(NSObject *)object {
NSDictionary *dictionary = (NSDictionary *)object;
+ NSArray *routeDics = [dictionary objectForKey:@"routes"];
+ routes = [[NSMutableArray alloc] initWithCapacity:[routeDics count]];
+ for (NSDictionary *routeDic in routeDics) {
+ [(NSMutableArray *)routes addObject:[UICGRoute routeWithDictionary:routeDic]];
+ }
+ self.geocodes = [dictionary objectForKey:@"geocodes"];
self.polyline = [UICGPolyline polylineWithDictionary:[dictionary objectForKey:@"polyline"]];
self.distance = [dictionary objectForKey:@"distance"];
self.duration = [dictionary objectForKey:@"duration"];
-
+ self.status = [dictionary objectForKey:@"status"];
if ([self.delegate respondsToSelector:@selector(directionsDidUpdateDirections:)]) {
[self.delegate directionsDidUpdateDirections:self];
@@ -58,14 +79,16 @@ - (void)goolgeMapsAPI:(UICGoogleMapsAPI *)goolgeMapsAPI didFailWithMessage:(NSSt
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
- NSLog(@"UICGDirections/webViewDidFinishLoad:");
+ isInitialized = YES;
if ([self.delegate respondsToSelector:@selector(directionsDidFinishInitialize:)]) {
[self.delegate directionsDidFinishInitialize:self];
}
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
- NSLog(@"UICGDirections/webView:didFailLoadWithError:");
+ if ([self.delegate respondsToSelector:@selector(directions:didFailInitializeWithError:)]) {
+ [self.delegate directions:self didFailInitializeWithError:error];
+ }
}
- (void)loadWithQuery:(NSString *)query options:(UICGDirectionsOptions *)options {
@@ -75,43 +98,32 @@ - (void)loadWithQuery:(NSString *)query options:(UICGDirectionsOptions *)options
- (void)loadWithStartPoint:(NSString *)startPoint endPoint:(NSString *)endPoint options:(UICGDirectionsOptions *)options {
[googleMapsAPI stringByEvaluatingJavaScriptFromString:
- [NSString stringWithFormat:@"loadDirections('%@', '%@', 'ja_JP')", startPoint, endPoint, [options JSONRepresentation]]];
+ [NSString stringWithFormat:@"loadDirections('%@', '%@', %@)", startPoint, endPoint, [options JSONRepresentation]]];
}
- (void)loadFromWaypoints:(NSArray *)waypoints options:(UICGDirectionsOptions *)options {
-
+ [googleMapsAPI stringByEvaluatingJavaScriptFromString:
+ [NSString stringWithFormat:@"loadFromWaypoints(%@, %@)", [waypoints JSONRepresentation], [options JSONRepresentation]]];
}
- (void)clear {
}
-- (NSDictionary *)status {
- return nil;
-}
-
- (NSInteger)numberOfRoutes {
- return 0;
+ return [routes count];
}
- (UICGRoute *)routeAtIndex:(NSInteger)index {
- return nil;
+ return [routes objectAtIndex:index];
}
- (NSInteger)numberOfGeocodes {
- return 0;
+ return [geocodes count];
}
- (NSDictionary *)geocodeAtIndex:(NSInteger)index {
- return nil;
-}
-
-- (NSDictionary *)distance {
- return nil;
-}
-
-- (NSDictionary *)duration {
- return nil;
+ return [geocodes objectAtIndex:index];;
}
@end
View
11 Classes/UICGDirectionsOptions.h
@@ -9,8 +9,8 @@
#import <Foundation/Foundation.h>
typedef enum UICGTravelModes {
- G_TRAVEL_MODE_DRIVING,
- G_TRAVEL_MODE_WALKING
+ UICGTravelModeDriving, // G_TRAVEL_MODE_DRIVING
+ UICGTravelModeWalking // G_TRAVEL_MODE_WALKING
} UICGTravelModes;
@interface UICGDirectionsOptions : NSObject {
@@ -22,4 +22,11 @@ typedef enum UICGTravelModes {
BOOL preserveViewport;
}
+@property (nonatomic, retain) NSLocale *locale;
+@property (nonatomic) UICGTravelModes travelMode;
+@property (nonatomic) BOOL avoidHighways;
+@property (nonatomic) BOOL getPolyline;
+@property (nonatomic) BOOL getSteps;
+@property (nonatomic) BOOL preserveViewport;
+
@end
View
36 Classes/UICGDirectionsOptions.m
@@ -10,4 +10,40 @@
@implementation UICGDirectionsOptions
+@synthesize locale;
+@synthesize travelMode;
+@synthesize avoidHighways;
+@synthesize getPolyline;
+@synthesize getSteps;
+@synthesize preserveViewport;
+
+- (id)init {
+ self = [super init];
+ if (self != nil) {
+ locale = [[NSLocale currentLocale] retain];
+ travelMode = UICGTravelModeDriving;
+ avoidHighways = NO;
+ getPolyline = YES;
+ getSteps = YES;
+ preserveViewport = NO;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [locale release];
+ [super dealloc];
+}
+
+- (NSString *)JSONRepresentation {
+ return [NSString stringWithFormat:
+ @"{ 'locale': '%@', travelMode: %@, avoidHighways: %@, getPolyline: %@, getSteps: %@, preserveViewport: %@}",
+ [locale localeIdentifier],
+ travelMode == UICGTravelModeDriving ? @"G_TRAVEL_MODE_DRIVING" : @"G_TRAVEL_MODE_WALKING",
+ avoidHighways ? @"true" : @"false",
+ getPolyline ? @"true" : @"false",
+ getSteps ? @"true" : @"false",
+ preserveViewport ? @"true" : @"false"];
+}
+
@end
View
24 Classes/UICGRoute.h
@@ -7,18 +7,34 @@
//
#import <Foundation/Foundation.h>
+#import <CoreLocation/CoreLocation.h>
#import "UICGStep.h"
@interface UICGRoute : NSObject {
- NSArray *array;
+ NSDictionary *dictionary;
NSInteger numerOfSteps;
- NSMutableArray *steps;
+ NSArray *steps;
NSDictionary *distance;
NSDictionary *duration;
+ NSString *summaryHtml;
+ NSDictionary *startGeocode;
+ NSDictionary *endGeocode;
+ CLLocation *endLocation;
+ NSInteger polylineEndIndex;
}
+@property (nonatomic, readonly) NSInteger numerOfSteps;
+@property (nonatomic, retain, readonly) NSArray *steps;
+@property (nonatomic, retain, readonly) NSDictionary *distance;
+@property (nonatomic, retain, readonly) NSDictionary *duration;
+@property (nonatomic, retain, readonly) NSString *summaryHtml;
+@property (nonatomic, retain, readonly) NSDictionary *startGeocode;
+@property (nonatomic, retain, readonly) NSDictionary *endGeocode;
+@property (nonatomic, retain, readonly) CLLocation *endLocation;
+@property (nonatomic, assign, readonly) NSInteger polylineEndIndex;
+
++ (UICGRoute *)routeWithDictionary:(NSDictionary *)dic;
+- (id)initWithDictionary:(NSDictionary *)dic;
- (UICGStep *)stepAtIndex:(NSInteger)index;
-- (id)startGeocode;
-- (id)endGeocode;
@end
View
61 Classes/UICGRoute.m
@@ -10,36 +10,63 @@
@implementation UICGRoute
-- (id)initWithSteps:(NSArray *)arr {
+@synthesize numerOfSteps;
+@synthesize steps;
+@synthesize distance;
+@synthesize duration;
+@synthesize summaryHtml;
+@synthesize startGeocode;
+@synthesize endGeocode;
+@synthesize endLocation;
+@synthesize polylineEndIndex;
+
++ (UICGRoute *)routeWithDictionary:(NSDictionary *)dic {
+ UICGRoute *route = [[UICGRoute alloc] initWithDictionary:dic];
+ return [route autorelease];
+}
+
+- (id)initWithDictionary:(NSDictionary *)dic {
self = [super init];
if (self != nil) {
- array = [arr retain];
- numerOfSteps = [array count];
- steps = [NSMutableArray arrayWithCapacity:numerOfSteps];
- for (NSDictionary *dic in array) {
- UICGStep *step = [UICGStep stepWithDictionary:dic];
- [steps addObject:step];
+ dictionary = [dic retain];
+ NSDictionary *k = [dictionary objectForKey:@"k"];
+ NSArray *stepDics = [k objectForKey:@"Steps"];
+ numerOfSteps = [stepDics count];
+ steps = [[NSMutableArray alloc] initWithCapacity:numerOfSteps];
+ for (NSDictionary *stepDic in stepDics) {
+ [(NSMutableArray *)steps addObject:[UICGStep stepWithDictionary:stepDic]];
}
+
+ endGeocode = [dictionary objectForKey:@"MJ"];
+ startGeocode = [dictionary objectForKey:@"dT"];
+
+ distance = [k objectForKey:@"Distance"];
+ duration = [k objectForKey:@"Duration"];
+ NSDictionary *endLocationDic = [k objectForKey:@"End"];
+ NSArray *coordinates = [endLocationDic objectForKey:@"coordinates"];
+ CLLocationDegrees longitude = [[coordinates objectAtIndex:0] doubleValue];
+ CLLocationDegrees latitude = [[coordinates objectAtIndex:1] doubleValue];
+ endLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
+ summaryHtml = [k objectForKey:@"summaryHtml"];
+ polylineEndIndex = [[k objectForKey:@"polylineEndIndex"] integerValue];
}
return self;
}
- (void)dealloc {
- [array release];
+ [dictionary release];
[steps release];
+ [distance release];
+ [duration release];
+ [summaryHtml release];
+ [startGeocode release];
+ [endGeocode release];
+ [endLocation release];
[super dealloc];
}
- (UICGStep *)stepAtIndex:(NSInteger)index {
- return nil;
-}
-
-- (id)startGeocode {
- return nil;
-}
-
-- (id)endGeocode {
- return nil;
+ return [steps objectAtIndex:index];;
}
@end
View
7 Classes/UICGStep.m
@@ -32,7 +32,12 @@ - (id)initWithDictionary:(NSDictionary *)dic {
CLLocationDegrees longitude = [[coordinates objectAtIndex:1] doubleValue];
location = [[[CLLocation alloc] initWithLatitude:latitude longitude:longitude] autorelease];
- polylineIndex = [[dictionary objectForKey:@"polylineIndex"] integerValue];
+ id index = [dictionary objectForKey:@"polylineIndex"];
+ if (index == [NSNull null]) {
+ polylineIndex = -1;
+ } else {
+ polylineIndex = [index integerValue];
+ }
descriptionHtml = [dictionary objectForKey:@"descriptionHtml"];
distance = [dictionary objectForKey:@"Distance"];
duration = [dictionary objectForKey:@"Duration"];
View
5 Classes/UICGoogleMapsAPI.h
@@ -16,7 +16,6 @@
- (void)goolgeMapsAPI:(UICGoogleMapsAPI *)goolgeMapsAPI didFailWithMessage:(NSString *)message;
@end
-@interface UICGoogleMapsAPI : UIWebView<UIWebViewDelegate> {
-}
-
+@interface UICGoogleMapsAPI : UIWebView<UIWebViewDelegate>
+- (void)makeAvailable;
@end
View
22 Classes/UICGoogleMapsAPI.m
@@ -10,17 +10,15 @@
#import "JSON.h"
@interface UIWebView(JavaScriptEvaluator)
-- (void)webView:(id)fp8 runJavaScriptAlertPanelWithMessage:(id)fp12 initiatedByFrame:(id)fp16;
+- (void)webView:(UIWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame;
@end
@implementation UICGoogleMapsAPI
- (id)init {
if (self = [super initWithFrame:CGRectZero]) {
- NSString *filePath = [[NSBundle mainBundle] pathForResource:@"api" ofType:@"html"];
- NSString *fileContents = [NSString stringWithContentsOfFile:filePath];
self.delegate = self;
- [self loadHTMLString:fileContents baseURL:[NSURL URLWithString:@"http://iphone.local/"]];
+ [self makeAvailable];
}
return self;
}
@@ -30,18 +28,26 @@ - (void)dealloc {
}
- (void)drawRect:(CGRect)rect {
- // Nothing to do;
+ // Nothing to do.
+}
+
+- (void)makeAvailable {
+ NSString *filePath = [[NSBundle mainBundle] pathForResource:@"api" ofType:@"html"];
+ NSString *fileContents = [NSString stringWithContentsOfFile:filePath];
+ [self loadHTMLString:fileContents baseURL:[NSURL URLWithString:@"http://iphone.local/"]];
}
- (void)webView:(UIWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame {
- if ([message hasPrefix:@"ERROR:"]) {
+// NSLog(@"%@", message);
+ id JSONValue = [message JSONValue];
+ if (!JSONValue) {
if ([self.delegate respondsToSelector:@selector(goolgeMapsAPI:didFailWithMessage:)]) {
- [self.delegate goolgeMapsAPI:self didFailWithMessage:message];
+ [(id<UICGoogleMapsAPIDelegate>)self.delegate goolgeMapsAPI:self didFailWithMessage:message];
}
return;
}
if ([self.delegate respondsToSelector:@selector(goolgeMapsAPI:didGetObject:)]) {
- [self.delegate goolgeMapsAPI:self didGetObject:[message JSONValue]];
+ [(id<UICGoogleMapsAPIDelegate>)self.delegate goolgeMapsAPI:self didGetObject:JSONValue];
}
}
View
1  Classes/UICRouteAnnotation.h
@@ -12,6 +12,7 @@
typedef enum UICRouteAnnotationType {
UICRouteAnnotationTypeStart,
UICRouteAnnotationTypeEnd,
+ UICRouteAnnotationTypeWayPoint,
} UICRouteAnnotationType;
@interface UICRouteAnnotation : NSObject<MKAnnotation> {
View
BIN  Icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 MapDirections-Info.plist
@@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
- <string></string>
+ <string>Icon.png</string>
<key>CFBundleIdentifier</key>
<string>com.kishikawakatsumi.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
@@ -22,6 +22,8 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
+ <key>UIPrerenderedIcon</key>
+ <true/>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSMainNibFile</key>
View
84 MapDirections.xcodeproj/project.pbxproj
@@ -26,6 +26,14 @@
14C88068102F583000079F9E /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 14C88067102F583000079F9E /* CoreLocation.framework */; };
14C88115102F610400079F9E /* UICRouteAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C88114102F610400079F9E /* UICRouteAnnotation.m */; };
14C882D0102F7E9400079F9E /* UICGStep.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C882CF102F7E9400079F9E /* UICGStep.m */; };
+ 14C883A31031A79300079F9E /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C883A21031A79300079F9E /* Icon.png */; };
+ 14C883DE1031AF7700079F9E /* reticle.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C883DD1031AF7700079F9E /* reticle.png */; };
+ 14C883E21031AF9500079F9E /* map_pin.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C883E01031AF9500079F9E /* map_pin.png */; };
+ 14C884E91031C5A500079F9E /* list.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C884E81031C5A500079F9E /* list.png */; };
+ 14C8852F1031CA0700079F9E /* RouteListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C8852E1031CA0700079F9E /* RouteListViewController.m */; };
+ 14C885E41031D50A00079F9E /* UICGClientGeocoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C885E31031D50A00079F9E /* UICGClientGeocoder.m */; };
+ 14C8878F1031EE0800079F9E /* add.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C8878E1031EE0800079F9E /* add.png */; };
+ 14C887911031EE4D00079F9E /* remove.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C887901031EE4D00079F9E /* remove.png */; };
1D3623260D0F684500981E51 /* MapDirectionsAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* MapDirectionsAppDelegate.m */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
@@ -72,6 +80,16 @@
14C88114102F610400079F9E /* UICRouteAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICRouteAnnotation.m; sourceTree = "<group>"; };
14C882CE102F7E9400079F9E /* UICGStep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICGStep.h; sourceTree = "<group>"; };
14C882CF102F7E9400079F9E /* UICGStep.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICGStep.m; sourceTree = "<group>"; };
+ 14C883A21031A79300079F9E /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = "<group>"; };
+ 14C883DD1031AF7700079F9E /* reticle.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = reticle.png; sourceTree = "<group>"; };
+ 14C883E01031AF9500079F9E /* map_pin.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = map_pin.png; sourceTree = "<group>"; };
+ 14C884E81031C5A500079F9E /* list.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = list.png; sourceTree = "<group>"; };
+ 14C8852D1031CA0700079F9E /* RouteListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RouteListViewController.h; sourceTree = "<group>"; };
+ 14C8852E1031CA0700079F9E /* RouteListViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RouteListViewController.m; sourceTree = "<group>"; };
+ 14C885E21031D50A00079F9E /* UICGClientGeocoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UICGClientGeocoder.h; sourceTree = "<group>"; };
+ 14C885E31031D50A00079F9E /* UICGClientGeocoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICGClientGeocoder.m; sourceTree = "<group>"; };
+ 14C8878E1031EE0800079F9E /* add.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add.png; sourceTree = "<group>"; };
+ 14C887901031EE4D00079F9E /* remove.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = remove.png; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D3623240D0F684500981E51 /* MapDirectionsAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapDirectionsAppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* MapDirectionsAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapDirectionsAppDelegate.m; sourceTree = "<group>"; };
@@ -115,6 +133,8 @@
28C286E00D94DF7D0034E888 /* RootViewController.m */,
14C87E6C102F358200079F9E /* MapDirectionsViewController.h */,
14C87E6D102F358200079F9E /* MapDirectionsViewController.m */,
+ 14C8852D1031CA0700079F9E /* RouteListViewController.h */,
+ 14C8852E1031CA0700079F9E /* RouteListViewController.m */,
);
path = Classes;
sourceTree = "<group>";
@@ -122,22 +142,8 @@
14C87D3B102F1FD900079F9E /* Library */ = {
isa = PBXGroup;
children = (
- 14C87E5F102F31C600079F9E /* UICRouteOverlayMapView.h */,
- 14C87E60102F31C600079F9E /* UICRouteOverlayMapView.m */,
- 14C88113102F610400079F9E /* UICRouteAnnotation.h */,
- 14C88114102F610400079F9E /* UICRouteAnnotation.m */,
- 14C87D38102F1FD500079F9E /* UICGDirections.h */,
- 14C87D39102F1FD500079F9E /* UICGDirections.m */,
- 14C87D3C102F20AD00079F9E /* UICGDirectionsOptions.h */,
- 14C87D3D102F20AD00079F9E /* UICGDirectionsOptions.m */,
- 14C87D40102F21A900079F9E /* UICGRoute.h */,
- 14C87D41102F21A900079F9E /* UICGRoute.m */,
- 14C882CE102F7E9400079F9E /* UICGStep.h */,
- 14C882CF102F7E9400079F9E /* UICGStep.m */,
- 14C87D43102F225F00079F9E /* UICGPolyline.h */,
- 14C87D44102F225F00079F9E /* UICGPolyline.m */,
- 14C87D96102F274300079F9E /* UICGoogleMapsAPI.h */,
- 14C87D97102F274300079F9E /* UICGoogleMapsAPI.m */,
+ 14C8839E1031A61700079F9E /* Google Maps API */,
+ 14C8839D1031A5A200079F9E /* MapKit Extention */,
);
name = Library;
sourceTree = "<group>";
@@ -162,6 +168,38 @@
name = JSON;
sourceTree = "<group>";
};
+ 14C8839D1031A5A200079F9E /* MapKit Extention */ = {
+ isa = PBXGroup;
+ children = (
+ 14C87E5F102F31C600079F9E /* UICRouteOverlayMapView.h */,
+ 14C87E60102F31C600079F9E /* UICRouteOverlayMapView.m */,
+ 14C88113102F610400079F9E /* UICRouteAnnotation.h */,
+ 14C88114102F610400079F9E /* UICRouteAnnotation.m */,
+ );
+ name = "MapKit Extention";
+ sourceTree = "<group>";
+ };
+ 14C8839E1031A61700079F9E /* Google Maps API */ = {
+ isa = PBXGroup;
+ children = (
+ 14C87D38102F1FD500079F9E /* UICGDirections.h */,
+ 14C87D39102F1FD500079F9E /* UICGDirections.m */,
+ 14C87D3C102F20AD00079F9E /* UICGDirectionsOptions.h */,
+ 14C87D3D102F20AD00079F9E /* UICGDirectionsOptions.m */,
+ 14C885E21031D50A00079F9E /* UICGClientGeocoder.h */,
+ 14C885E31031D50A00079F9E /* UICGClientGeocoder.m */,
+ 14C87D40102F21A900079F9E /* UICGRoute.h */,
+ 14C87D41102F21A900079F9E /* UICGRoute.m */,
+ 14C882CE102F7E9400079F9E /* UICGStep.h */,
+ 14C882CF102F7E9400079F9E /* UICGStep.m */,
+ 14C87D43102F225F00079F9E /* UICGPolyline.h */,
+ 14C87D44102F225F00079F9E /* UICGPolyline.m */,
+ 14C87D96102F274300079F9E /* UICGoogleMapsAPI.h */,
+ 14C87D97102F274300079F9E /* UICGoogleMapsAPI.m */,
+ );
+ name = "Google Maps API";
+ sourceTree = "<group>";
+ };
19C28FACFE9D520D11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
@@ -194,6 +232,12 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ 14C883A21031A79300079F9E /* Icon.png */,
+ 14C8878E1031EE0800079F9E /* add.png */,
+ 14C887901031EE4D00079F9E /* remove.png */,
+ 14C883DD1031AF7700079F9E /* reticle.png */,
+ 14C883E01031AF9500079F9E /* map_pin.png */,
+ 14C884E81031C5A500079F9E /* list.png */,
2899E55F0DE3E45000AC0155 /* RootViewController.xib */,
28AD735F0D9D9599002E5188 /* MainWindow.xib */,
8D1107310486CEB800E47090 /* MapDirections-Info.plist */,
@@ -267,6 +311,12 @@
28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */,
2899E5600DE3E45000AC0155 /* RootViewController.xib in Resources */,
14C87D95102F260A00079F9E /* api.html in Resources */,
+ 14C883A31031A79300079F9E /* Icon.png in Resources */,
+ 14C883DE1031AF7700079F9E /* reticle.png in Resources */,
+ 14C883E21031AF9500079F9E /* map_pin.png in Resources */,
+ 14C884E91031C5A500079F9E /* list.png in Resources */,
+ 14C8878F1031EE0800079F9E /* add.png in Resources */,
+ 14C887911031EE4D00079F9E /* remove.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -295,6 +345,8 @@
14C87E6E102F358200079F9E /* MapDirectionsViewController.m in Sources */,
14C88115102F610400079F9E /* UICRouteAnnotation.m in Sources */,
14C882D0102F7E9400079F9E /* UICGStep.m in Sources */,
+ 14C8852F1031CA0700079F9E /* RouteListViewController.m in Sources */,
+ 14C885E41031D50A00079F9E /* UICGClientGeocoder.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
BIN  add.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
25 api.html
@@ -20,34 +20,36 @@
}
}
- function loadDirections(fromAddress, toAddress, locale) {
- gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale, getPolyline: true, getSteps: true });
+ function loadDirections(from, to, options) {
+ gdir.load("from: " + from + " to: " + to, options);
+ }
+
+ function loadFromWaypoints(waypoints, options) {
+ gdir.loadFromWaypoints(waypoints, options);
}
function handleErrors() {
if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
- alert("ERROR: No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
+ alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
- alert("ERROR: A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
+ alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
- alert("ERROR: The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
+ alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
//else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS) <--- Doc bug... this is either not defined, or Doc is wrong
// alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_KEY)
- alert("ERROR: The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
+ alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
- alert("ERROR: A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
+ alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
- else alert("ERROR: An unknown error occurred.");
+ else alert("An unknown error occurred.");
}
function onGDirectionsLoad() {
- var polyline = gdir.getPolyline();
-
var numRoutes = gdir.getNumRoutes();
var routes = new Array(numRoutes);
for (var i = 0; i < numRoutes; i++) {
@@ -63,7 +65,8 @@
"geocodes": geocodes,
"distance": gdir.getDistance(),
"duration": gdir.getDuration(),
- "polyline": polyline }.toSource());
+ "polyline": gdir.getPolyline(),
+ "status": gdir.getStatus() }.toSource());
}
(function () {
View
BIN  list.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  map_pin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  remove.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  reticle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.