Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sarah Lensing
committed
Apr 10, 2017
1 parent
ad3040c
commit 6baa00c
Showing
9 changed files
with
338 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
# Position, rotation, and zoom | ||
# Position, rotation, zoom, and tilt | ||
|
||
When the map style finishes loading, your `OnStyleLoaded` closure will be executed and you can begin to manipulate the map. Set the position, rotation, zoom, and tilt as follows: | ||
|
||
```swift | ||
import Foundation | ||
import TangramMap | ||
|
||
class PositionExampleViewController: MZMapViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
_ = try? loadStyleAsync(.bubbleWrap) { [unowned self] (style) in | ||
self.position = TGGeoPointMake(-73.9903, 40.74433) | ||
self.rotation = 0 | ||
self.zoom = 17 | ||
self.tilt = 0 | ||
} | ||
} | ||
|
||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,82 @@ | ||
# Gesture Responders | ||
|
||
The map supports taps, double taps, shoves, scales, rotations, pans, and long presses. To receive information about when these events occur, create a responder. | ||
|
||
```swift | ||
import Foundation | ||
import UIKit | ||
|
||
class GestureExampleViewController: MZMapViewController, MapSingleTapGestureDelegate, MapDoubleTapGestureDelegate, MapLongPressGestureDelegate, MapPanGestureDelegate, MapPinchGestureDelegate, MapRotateGestureDelegate, MapShoveGestureDelegate { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
try? loadStyleAsync(.bubbleWrap) { [unowned self] (style) in | ||
self.setupDelegates() | ||
} | ||
} | ||
|
||
//MARK: Private | ||
private func setupDelegates() { | ||
self.singleTapGestureDelegate = self | ||
self.doubleTapGestureDelegate = self | ||
self.longPressGestureDelegate = self | ||
self.panDelegate = self | ||
self.pinchDelegate = self | ||
self.rotateDelegate = self | ||
self.shoveDelegate = self | ||
} | ||
|
||
private func logGesture(_ gesture: String) { | ||
print("Gesture: \(gesture)") | ||
} | ||
|
||
//MARK: MapSingleTapGestureDelegate | ||
func mapController(_ controller: MZMapViewController, recognizer: UIGestureRecognizer, shouldRecognizeSingleTapGesture location: CGPoint) -> Bool { | ||
return true | ||
} | ||
|
||
|
||
func mapController(_ controller: MZMapViewController, recognizer: UIGestureRecognizer, didRecognizeSingleTapGesture location: CGPoint) { | ||
logGesture("Single tap") | ||
} | ||
|
||
//MARK: MapDoubleTapGestureDelegate | ||
func mapController(_ controller: MZMapViewController, recognizer: UIGestureRecognizer, shouldRecognizeDoubleTapGesture location: CGPoint) -> Bool { | ||
return true | ||
} | ||
|
||
func mapController(_ controller: MZMapViewController, recognizer: UIGestureRecognizer, didRecognizeDoubleTapGesture location: CGPoint) { | ||
logGesture("Double tap") | ||
} | ||
|
||
//MARK: MapLongPressGestureDelegate | ||
func mapController(_ controller: MZMapViewController, recognizer: UIGestureRecognizer, shouldRecognizeLongPressGesture location: CGPoint) -> Bool { | ||
return true | ||
} | ||
|
||
func mapController(_ controller: MZMapViewController, recognizer: UIGestureRecognizer, didRecognizeLongPressGesture location: CGPoint) { | ||
logGesture("Long press") | ||
} | ||
|
||
//MARK: MapPanGestureDelegate | ||
func mapController(_ controller: MZMapViewController, didPanMap displacement: CGPoint) { | ||
logGesture("Pan") | ||
} | ||
|
||
//MARK: MapPinchGestureDelegate | ||
func mapController(_ controller: MZMapViewController, didPinchMap location: CGPoint) { | ||
logGesture("Pinch") | ||
} | ||
|
||
//MARK: MapRotateGestureDelegate | ||
func mapController(_ controller: MZMapViewController, didRotateMap location: CGPoint) { | ||
logGesture("Rotate") | ||
} | ||
|
||
//MARK: MapShoveGestureDelegate | ||
func mapController(_ controller: MZMapViewController, didShoveMap displacement: CGPoint) { | ||
logGesture("Shove") | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Location Services | ||
It is extremely easy to show the user's current location on the map. Simply call `MZMapViewController#showCurrentLocation(true)` to display an icon on the map. The iOS SDK also supports visually tracking and centering on the user's current location. To display a button to enable this behavior, call `MZMapViewController#showFindMeButon(true)`. | ||
|
||
```swift | ||
class LocationExampleViewController: MZMapViewController { | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
try? loadStyleAsync(.bubbleWrap) { [unowned self] (style) in | ||
_ = self.showCurrentLocation(true) | ||
_ = self.showFindMeButon(true) | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Mapzen Places | ||
|
||
Coming soon! | ||
We will be building this feature soon. Track its progress [here](https://github.com/mapzen/ios/issues). Feel free to create issues or submit pull requests, we welcome outside contributions! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,45 @@ | ||
# Search | ||
|
||
## Getting Started | ||
Be sure to sign up for an API key as described [here](https://mapzen.com/documentation/ios/getting-started/). After you have a key configured in your app, use the main entry point, `MapzenSearch`, for executing search-related queries. | ||
|
||
## Search | ||
Find a place by searching for an address or name. | ||
|
||
```swift | ||
private func search() { | ||
let config = SearchConfig.init(searchText: "pizza") { (response) in | ||
// display result | ||
} | ||
_ = MapzenSearch.sharedInstance.search(config) | ||
} | ||
``` | ||
|
||
## Autocomplete | ||
Get real-time result suggestions without having to type the whole location. | ||
Get real-time result suggestions with autocomplete. | ||
|
||
```swift | ||
private func autocomplete() { | ||
let point = GeoPoint.init(latitude: 40.74433, longitude: -73.9903) | ||
let config = AutocompleteConfig.init(searchText: "pizza", focusPoint: point) { (response) in | ||
// display result | ||
} | ||
_ = MapzenSearch.sharedInstance.autocompleteQuery(config) | ||
} | ||
``` | ||
|
||
## Reverse | ||
Find what is located at a certain coordinate location. | ||
|
||
```swift | ||
private func reverseGeo() { | ||
let point = GeoPoint.init(latitude: 40.74433, longitude: -73.9903) | ||
let config = ReverseConfig.init(point: point) { (response) in | ||
// display result | ||
} | ||
_ = MapzenSearch.sharedInstance.reverseGeocode(config) | ||
} | ||
``` | ||
|
||
## Place | ||
Get rich details about a place. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,69 @@ | ||
# Switching Styles | ||
The map’s style can be configured with `MZMapViewController#loadStyleAsync`. We recommend using the asynchronous method which takes an `OnStyleLoaded` closure however, the style can also be updated synchronously. | ||
|
||
```swift | ||
import UIKit | ||
import TangramMap | ||
class StyleExampleViewController: MZMapViewController { | ||
|
||
private var styleLoaded = false | ||
|
||
lazy var activityIndicator : UIActivityIndicatorView = { | ||
let indicator = UIActivityIndicatorView.init(activityIndicatorStyle: .whiteLarge) | ||
indicator.color = .black | ||
indicator.translatesAutoresizingMaskIntoConstraints = false | ||
self.view.addSubview(indicator) | ||
|
||
let xConstraint = indicator.centerXAnchor.constraint(equalTo: self.view.centerXAnchor) | ||
let yConstraint = indicator.centerYAnchor.constraint(equalTo: self.view.centerYAnchor) | ||
NSLayoutConstraint.activate([xConstraint, yConstraint]) | ||
|
||
return indicator | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setupSwitchStyleBtn() | ||
try? loadStyleAsync(.bubbleWrap) { [unowned self] (style) in | ||
self.styleLoaded = true | ||
} | ||
} | ||
|
||
//MARK: Private | ||
private func setupSwitchStyleBtn() { | ||
let btn = UIBarButtonItem.init(title: "Map Style", style: .plain, target: self, action: #selector(showStyleActionSheet)) | ||
self.navigationItem.rightBarButtonItem = btn | ||
} | ||
|
||
@objc private func showStyleActionSheet() { | ||
let actionSheet = UIAlertController.init(title: "Map Style", message: "Choose a map style", preferredStyle: .actionSheet) | ||
actionSheet.addAction(UIAlertAction.init(title: "Bubble Wrap", style: .default, handler: { [unowned self] (action) in | ||
self.indicateLoadStyle(style: .bubbleWrap) | ||
})) | ||
actionSheet.addAction(UIAlertAction.init(title: "Cinnabar", style: .default, handler: { [unowned self] (action) in | ||
self.indicateLoadStyle(style: .cinnabar) | ||
})) | ||
actionSheet.addAction(UIAlertAction.init(title: "Refill", style: .default, handler: { [unowned self] (action) in | ||
self.indicateLoadStyle(style: .refill) | ||
})) | ||
actionSheet.addAction(UIAlertAction.init(title: "Walkabout", style: .default, handler: { [unowned self] (action) in | ||
self.indicateLoadStyle(style: .walkabout) | ||
})) | ||
actionSheet.addAction(UIAlertAction.init(title: "Zinc", style: .default, handler: { [unowned self] (action) in | ||
self.indicateLoadStyle(style: .zinc) | ||
})) | ||
actionSheet.addAction(UIAlertAction.init(title: "Cancel", style: .cancel, handler: { [unowned self] (action) in | ||
self.dismiss(animated: true, completion: nil) | ||
})) | ||
self.navigationController?.present(actionSheet, animated: true, completion: nil) | ||
} | ||
|
||
private func indicateLoadStyle(style: MapStyle) { | ||
activityIndicator.startAnimating() | ||
try? loadStyleAsync(style, onStyleLoaded: { [unowned self] (style) in | ||
self.activityIndicator.stopAnimating() | ||
}) | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
# Turn-by-Turn | ||
|
||
## Getting Started | ||
Be sure to sign up for an API key as described [here](https://mapzen.com/documentation/ios/getting-started/). After you have a key configured in your app, use the main entry point, `RoutingController`, for executing turn-by-turn queries. | ||
|
||
## Fetch Route | ||
To fetch a route you need to give the router a list of locations and a costing model at minimum. The first and last locations must be "break" points. To configure costing options see the turn-by-turn [costing options documentation](https://mapzen.com/documentation/mobility/turn-by-turn/api-reference/#costing-options) for available parameters. And, to configure directions options such as the units, see the [directions options documentation](https://mapzen.com/documentation/mobility/turn-by-turn/api-reference/#directions-options). | ||
|
||
## Track User's Progress Along Route | ||
```swift | ||
let router = try? RoutingController.controller() | ||
let locations = [ | ||
OTRRoutingPoint.init(coordinate: OTRGeoPoint.init(latitude: 40.74433, longitude: -73.9903), type: .break), | ||
OTRRoutingPoint.init(coordinate: OTRGeoPoint.init(latitude: 40.734807, longitude: -73.984770), type: .through), | ||
OTRRoutingPoint.init(coordinate: OTRGeoPoint.init(latitude: 40.732172, longitude: -73.998674), type: .through), | ||
OTRRoutingPoint.init(coordinate: OTRGeoPoint.init(latitude: 40.741050, longitude: -73.996142), type: .break) | ||
] | ||
_ = router?.requestRoute(withLocations: locations, costingModel: .auto, costingOption: nil, directionsOptions: nil) { (result, asd, error) in | ||
// | ||
} | ||
``` |