Skip to content

Commit

Permalink
Centralize API Key Manager and Implement Route Line Drawing (#144)
Browse files Browse the repository at this point in the history
* Centralizes API Key Management

Fixes #136

* Add route line drawing capability

Also some minor API cleanup

* Update cocoapods, add minor button for viewing routing list

* Delete provisioning profile and let CircleCI manage

* Fixes from CR
  • Loading branch information
msmollin authored and ecgreb committed Jan 19, 2017
1 parent 6e9cc48 commit c024690
Show file tree
Hide file tree
Showing 15 changed files with 313 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Podfile.lock
Expand Up @@ -23,13 +23,13 @@ EXTERNAL SOURCES:

CHECKOUT OPTIONS:
OnTheRoad:
:commit: 65871d9f1d8e92987730f42c24114c4b6458c582
:commit: 28aec7e3a076e1e07c7b1d0bb59531673d88b415
:git: https://github.com/mapzen/on-the-road_ios.git
Pelias:
:commit: a8d8b0fe8800304b31694a179dd45428d5de75b8
:git: https://github.com/pelias/pelias-ios-sdk.git
Tangram-es:
:commit: c09e4d07980b6178f7f9f11d10a3061f08450228
:commit: 9ee8a5d61cce2f0530f67004484435dbd589507e
:git: https://github.com/tangrams/ios-framework.git

SPEC CHECKSUMS:
Expand Down
1 change: 1 addition & 0 deletions SampleApp/AppDelegate.swift
Expand Up @@ -16,6 +16,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
MapzenManager.sharedManager.apiKey = "mapzen-2qQR7SX"
return true
}

Expand Down
2 changes: 0 additions & 2 deletions SampleApp/AutocompleteTableVC.swift
Expand Up @@ -27,8 +27,6 @@ class AutocompleteTableVC: UITableViewController, UISearchResultsUpdating, UISea
self.definesPresentationContext = true
searchController.searchBar.sizeToFit()
manager.delegate = self
PeliasSearchManager.sharedInstance.urlQueryItems = [NSURLQueryItem(name: "api_key", value: "mapzen-2qQR7SX")]

}

override func viewDidAppear(animated: Bool) {
Expand Down
44 changes: 37 additions & 7 deletions SampleApp/Base.lproj/Main.storyboard
Expand Up @@ -83,7 +83,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3Su-ks-AkJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1729" y="457"/>
<point key="canvasLocation" x="1305" y="457"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="y44-Ze-QWp">
Expand Down Expand Up @@ -146,7 +146,7 @@
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bee-Yr-DhB">
<rect key="frame" x="0.0" y="118" width="375" height="500"/>
<connections>
<segue destination="u5O-OL-dVh" kind="embed" identifier="routeResultEmbedSegue" id="BVM-lF-fck"/>
<segue destination="Y88-cs-1iJ" kind="embed" identifier="routeResultEmbedSegue" id="lzJ-gT-R0K"/>
</connections>
</containerView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5zL-5j-Qgk">
Expand All @@ -158,13 +158,23 @@
<segue destination="mHh-a7-7co" kind="show" identifier="showRouteSearchSegue" id="ZFg-Hq-SIh"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ao9-Bf-Lhy">
<rect key="frame" x="271" y="580" width="88" height="30"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
<state key="normal" title="View Results"/>
<connections>
<segue destination="u5O-OL-dVh" kind="show" identifier="routeListSegue" id="CUu-hl-vj3"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Ao9-Bf-Lhy" firstAttribute="leading" secondItem="bee-Yr-DhB" secondAttribute="trailing" constant="-104" id="1VT-JF-osq"/>
<constraint firstItem="5zL-5j-Qgk" firstAttribute="top" secondItem="HlV-N5-ODf" secondAttribute="bottom" id="4WT-jY-Atz"/>
<constraint firstItem="vJT-wr-8yd" firstAttribute="top" secondItem="HlV-N5-ODf" secondAttribute="bottom" constant="8" id="7Wu-yB-RLd"/>
<constraint firstItem="5zL-5j-Qgk" firstAttribute="leading" secondItem="rqs-Ck-q5k" secondAttribute="leadingMargin" constant="-16" id="99G-Kg-ymi"/>
<constraint firstAttribute="trailingMargin" secondItem="5zL-5j-Qgk" secondAttribute="trailing" constant="-16" id="Aun-pu-mDG"/>
<constraint firstItem="Ao9-Bf-Lhy" firstAttribute="top" secondItem="bee-Yr-DhB" secondAttribute="bottom" constant="-38" id="DXW-a7-00S"/>
<constraint firstItem="bee-Yr-DhB" firstAttribute="top" secondItem="5zL-5j-Qgk" secondAttribute="bottom" constant="8" id="Emx-nB-2P4"/>
<constraint firstAttribute="leadingMargin" secondItem="vJT-wr-8yd" secondAttribute="leading" id="NCP-6q-GRz"/>
<constraint firstAttribute="trailingMargin" secondItem="bee-Yr-DhB" secondAttribute="trailing" constant="-16" id="Uot-Z6-yGf"/>
Expand Down Expand Up @@ -218,7 +228,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iHt-Qg-omp" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2049" y="1815"/>
<point key="canvasLocation" x="2063" y="1236"/>
</scene>
<!--Route-->
<scene sceneID="HRj-0v-iQO">
Expand All @@ -237,12 +247,32 @@
</objects>
<point key="canvasLocation" x="396" y="2104"/>
</scene>
<!--GLKit View Controller-->
<scene sceneID="ee1-th-oeJ">
<objects>
<glkViewController preferredFramesPerSecond="30" id="Y88-cs-1iJ" customClass="RouteDisplayViewController" customModule="ios_sdk" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="LiY-jv-RNx"/>
<viewControllerLayoutGuide type="bottom" id="ecQ-JS-Jox"/>
</layoutGuides>
<glkView key="view" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" enableSetNeedsDisplay="NO" id="Z9r-vc-1vH">
<rect key="frame" x="0.0" y="0.0" width="375" height="500"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<connections>
<outlet property="delegate" destination="Y88-cs-1iJ" id="hD5-P8-MR7"/>
</connections>
</glkView>
</glkViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="ZlR-tZ-geG" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1818" y="2816"/>
</scene>
<!--Routing Result TableVC-->
<scene sceneID="rXB-in-08Y">
<objects>
<tableViewController id="u5O-OL-dVh" customClass="RoutingResultTableVC" customModule="ios_sdk" customModuleProvider="target" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="Sse-sB-OtU">
<rect key="frame" x="0.0" y="0.0" width="375" height="500"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<prototypes>
Expand All @@ -254,13 +284,13 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cqh-Nl-kb2">
<rect key="frame" x="17" y="11" width="276" height="21.5"/>
<rect key="frame" x="17" y="11" width="276" height="22"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jqy-T7-rV6">
<rect key="frame" x="301" y="11" width="66" height="21.5"/>
<rect key="frame" x="301" y="11" width="66" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="66" id="lmP-AU-dO7"/>
</constraints>
Expand Down Expand Up @@ -293,7 +323,7 @@
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4PT-xg-nH0" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2029.5999999999999" y="2464.7676161919044"/>
<point key="canvasLocation" x="2145" y="2068"/>
</scene>
</scenes>
</document>
25 changes: 25 additions & 0 deletions SampleApp/RouteDisplayViewController.swift
@@ -0,0 +1,25 @@
//
// RouteDisplayViewController.swift
// ios-sdk
//
// Created by Matt Smollinger on 1/15/17.
// Copyright © 2017 Mapzen. All rights reserved.
//

import UIKit
import OnTheRoad

class RouteDisplayViewController: MapViewController {

var routingResult: OTRRoutingResult?

override func viewDidLoad() {
super.viewDidLoad()
let _ = try? loadScene("scene.yaml")
}

func show(route : OTRRoutingResult){
routingResult = route
let _ = try? display(route)
}
}
14 changes: 11 additions & 3 deletions SampleApp/RoutingViewController.swift
Expand Up @@ -19,7 +19,9 @@ class RoutingViewController: UIViewController, RoutingSearchDelegate {
@IBOutlet weak var searchBar: UITextField!
let routeSearchSegueID = "showRouteSearchSegue"
let routeResultEmbedSegueID = "routeResultEmbedSegue"
var routeResultTable : RoutingResultTableVC?
let routeListSegueId = "routeListSegue"
var routeResultTable : RouteDisplayViewController?
var currentRouteResult: OTRRoutingResult?

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
guard let identifier = segue.identifier else {
Expand All @@ -32,10 +34,15 @@ class RoutingViewController: UIViewController, RoutingSearchDelegate {
}
break
case routeResultEmbedSegueID:
if let resultVC = segue.destinationViewController as? RoutingResultTableVC {
if let resultVC = segue.destinationViewController as? RouteDisplayViewController {
routeResultTable = resultVC
}
break
case routeListSegueId:
guard let routeResult = currentRouteResult else { return }
if let vc = segue.destinationViewController as? RoutingResultTableVC {
vc.routingResult = routeResult
}
default:
break
}
Expand Down Expand Up @@ -67,7 +74,8 @@ class RoutingViewController: UIViewController, RoutingSearchDelegate {
directionsOptions: ["units" : "miles"]) { (routingResult, token, error) in
print(routingResult?.legs);
print("Error:\(error)")
self.routeResultTable?.display(routingResult!)
self.currentRouteResult = routingResult
self.routeResultTable?.show(routingResult!)

}

Expand Down
3 changes: 1 addition & 2 deletions SampleApp/SearchPinsViewController.swift
Expand Up @@ -15,8 +15,7 @@ class SearchPinsViewController: MapViewController, UITextFieldDelegate {

override func viewDidLoad() {
super.viewDidLoad()
self.loadScene("scene.yaml", apiKey: "mapzen-2qQR7SX")
PeliasSearchManager.sharedInstance.urlQueryItems = [NSURLQueryItem(name: "api_key", value: "mapzen-2qQR7SX")]
let _ = try? loadScene("scene.yaml")

searchField.delegate = self
}
Expand Down
2 changes: 1 addition & 1 deletion SampleApp/TangramVC.swift
Expand Up @@ -12,7 +12,7 @@ class TangramVC: MapViewController{

override func viewDidLoad() {
super.viewDidLoad()
self.loadScene("scene.yaml", apiKey: "mapzen-2qQR7SX")
let _ = try? loadScene("scene.yaml")
}

override func viewDidAppear(animated: Bool) {
Expand Down
Binary file removed adhoc.mobileprovision
Binary file not shown.
16 changes: 16 additions & 0 deletions ios-sdk.xcodeproj/project.pbxproj
Expand Up @@ -9,6 +9,10 @@
/* Begin PBXBuildFile section */
AC586709D7E7D4C22AA9474D /* Pods_ios_sdk.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99B3EC60450343448FA4E699 /* Pods_ios_sdk.framework */; };
C8F52AC1BCE46BB17E1CE0A5 /* Pods_ios_sdkTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A3EA87256F2EA6D0C43260A /* Pods_ios_sdkTests.framework */; };
DB188EEA1E2846600054DEFD /* MapzenManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB188EE91E2846600054DEFD /* MapzenManager.swift */; };
DB188EEC1E28492A0054DEFD /* MapzenManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB188EEB1E28492A0054DEFD /* MapzenManagerTests.swift */; };
DB188EEE1E290D310054DEFD /* MapzenRoutingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB188EED1E290D310054DEFD /* MapzenRoutingController.swift */; };
DB188EF01E2C44F40054DEFD /* RouteDisplayViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB188EEF1E2C44F40054DEFD /* RouteDisplayViewController.swift */; };
DB217BF21E00EAED00D3116E /* building-grid.gif in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBC869A11D3666B300DDC4FE /* building-grid.gif */; };
DB217BF31E00EAF000D3116E /* poi_icons_18@2x.png in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBC869A21D3666B300DDC4FE /* poi_icons_18@2x.png */; };
DB22E59A1DA45D73004264E0 /* RoutingSearchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB22E5991DA45D73004264E0 /* RoutingSearchVC.swift */; };
Expand Down Expand Up @@ -70,6 +74,10 @@
99B3EC60450343448FA4E699 /* Pods_ios_sdk.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ios_sdk.framework; sourceTree = BUILT_PRODUCTS_DIR; };
A8BB69C349D7314906580508 /* Pods-ios-sdkTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios-sdkTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ios-sdkTests/Pods-ios-sdkTests.release.xcconfig"; sourceTree = "<group>"; };
B96DEBA552AA3AAEA9CDF6F4 /* Pods-ios-sdk.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ios-sdk.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ios-sdk/Pods-ios-sdk.debug.xcconfig"; sourceTree = "<group>"; };
DB188EE91E2846600054DEFD /* MapzenManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapzenManager.swift; sourceTree = "<group>"; };
DB188EEB1E28492A0054DEFD /* MapzenManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapzenManagerTests.swift; sourceTree = "<group>"; };
DB188EED1E290D310054DEFD /* MapzenRoutingController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapzenRoutingController.swift; sourceTree = "<group>"; };
DB188EEF1E2C44F40054DEFD /* RouteDisplayViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RouteDisplayViewController.swift; sourceTree = "<group>"; };
DB22E5991DA45D73004264E0 /* RoutingSearchVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoutingSearchVC.swift; sourceTree = "<group>"; };
DB22E59B1DA46640004264E0 /* RoutingResultTableVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoutingResultTableVC.swift; sourceTree = "<group>"; };
DB22E59D1DA473CA004264E0 /* RouteDirectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RouteDirectionCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -205,6 +213,7 @@
DB22E59B1DA46640004264E0 /* RoutingResultTableVC.swift */,
DB22E59D1DA473CA004264E0 /* RouteDirectionCell.swift */,
DBFB759C1E20345500CF6173 /* SearchPinsViewController.swift */,
DB188EEF1E2C44F40054DEFD /* RouteDisplayViewController.swift */,
);
path = SampleApp;
sourceTree = "<group>";
Expand All @@ -214,6 +223,7 @@
children = (
DB7A33EE1C8F8E8B009CC743 /* Info.plist */,
DBCBC5BE1E0AE1CF0045B345 /* MapViewControllerTests.swift */,
DB188EEB1E28492A0054DEFD /* MapzenManagerTests.swift */,
);
path = "ios-sdkTests";
sourceTree = "<group>";
Expand All @@ -225,6 +235,8 @@
DB70FEA81DE3425800249509 /* MapViewController.swift */,
DB5B31501DE4A173005EB816 /* LocationManager.swift */,
DBFB759E1E2046D100CF6173 /* TangramExtensions.swift */,
DB188EE91E2846600054DEFD /* MapzenManager.swift */,
DB188EED1E290D310054DEFD /* MapzenRoutingController.swift */,
);
path = src;
sourceTree = "<group>";
Expand Down Expand Up @@ -464,13 +476,16 @@
files = (
DBFB759F1E2046D100CF6173 /* TangramExtensions.swift in Sources */,
DBFB759D1E20345500CF6173 /* SearchPinsViewController.swift in Sources */,
DB188EEA1E2846600054DEFD /* MapzenManager.swift in Sources */,
DBF441AE1D351B0A007DEE95 /* TangramVC.swift in Sources */,
DB22E59E1DA473CA004264E0 /* RouteDirectionCell.swift in Sources */,
DB5B31511DE4A173005EB816 /* LocationManager.swift in Sources */,
DBC869921D3663C700DDC4FE /* PeliasMapkitExtensions.swift in Sources */,
DB188EEE1E290D310054DEFD /* MapzenRoutingController.swift in Sources */,
DB70FEA91DE3425800249509 /* MapViewController.swift in Sources */,
DB22E59A1DA45D73004264E0 /* RoutingSearchVC.swift in Sources */,
DBBF368B1D64DA6A0069D769 /* RoutingViewController.swift in Sources */,
DB188EF01E2C44F40054DEFD /* RouteDisplayViewController.swift in Sources */,
DB22E59C1DA46640004264E0 /* RoutingResultTableVC.swift in Sources */,
DBC869901D3662DD00DDC4FE /* AutocompleteTableVC.swift in Sources */,
DB7A33D81C8F8E8B009CC743 /* AppDelegate.swift in Sources */,
Expand All @@ -481,6 +496,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DB188EEC1E28492A0054DEFD /* MapzenManagerTests.swift in Sources */,
DBCBC5BF1E0AE1CF0045B345 /* MapViewControllerTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

0 comments on commit c024690

Please sign in to comment.