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
@objc func send() { | |
let img = createMapImage() | |
let sticker = SCSDKSnapSticker(stickerImage: img) | |
let snap = SCSDKNoSnapContent() | |
snap.sticker = sticker | |
snap.attachmentUrl = "https://developer.here.com" | |
let api = SCSDKSnapAPI(content: snap) | |
api.startSnapping { (error) in } | |
} |
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
let button = UIButton(frame: CGRect(x: 0, y: 0, width: 150, height: 50)) | |
button.setTitle("Send to Snapchat", for: .normal) | |
button.setTitleColor(self.view.tintColor, for: .normal) | |
self.view.addSubview(button) | |
button.center = self.view.center | |
button.addTarget(self, action: #selector(self.send), for: .touchUpInside) |
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
import UIKit | |
import SCSDKCreativeKit | |
import CoreLocation |
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
func createMapImage() -> UIImage { | |
struct here { | |
static var id = "YOUR-HERE-APP-ID" | |
static var code = "YOUR-HERE-APP-CODE" | |
} | |
let lat = locationManager.location!.coordinate.latitude | |
let long = locationManager.location!.coordinate.longitude | |
//Map Image API parameters |
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
let location = locationManager.location!.coordinate |
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
import UIKit | |
import CoreLocation | |
class ViewController: UIViewController, CLLocationManagerDelegate { | |
var locationManager = CLLocationManager() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
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
<key>SCSDKClientId</key> | |
<string>YOUR-SNAPKIT-KEY</string> | |
<key>SCSDKRedirectUrl</key> | |
<string>https://developer.here.com</string> | |
<key>LSApplicationQueriesSchemes</key> | |
<array> | |
<string>snapchat</string> | |
</array> | |
<key>CFBundleURLTypes</key> | |
<array> |
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
var onResult = function(result) { | |
var center = new H.geo.Point(result.response.center.latitude, result.response.center.longitude), | |
isolineCoords = result.response.isoline[0].component[0].shape, | |
linestring = new H.geo.LineString(), | |
isolinePolygon, | |
isolineCenter; | |
// Add the returned isoline coordinates to a linestring | |
isolineCoords.forEach(function(coords) { | |
linestring.pushLatLngAlt.apply(linestring, coords.split(',')); |
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
function startIsolineRouting() { | |
// Set up the Routing API parameters | |
var routingParams = { | |
'mode': 'fastest;car;traffic:enabled', // traffic matters for our commute | |
'start': startPosition, | |
'departure': '2018-07-16T17:00:00', // let's leave the office at 5pm | |
'rangetype': 'time', // how far can get in 30 minutes? | |
'range': '240' // 30 minutes = 1800 seconds | |
}; |
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
// Set a new starting position (office) when the user clicks the map | |
map.addEventListener('tap', function (evt) { | |
var coord = map.screenToGeo(evt.currentPointer.viewportX, evt.currentPointer.viewportY); | |
startPosition = coord.lat + ',' + coord.lng; | |
startIsolineRouting(); | |
}); |