Skip to content

Instantly share code, notes, and snippets.

View here-devblog-gists's full-sized avatar

here-devblog-gists

  • HERE Technologies
View GitHub Profile
@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 }
}
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)
import UIKit
import SCSDKCreativeKit
import CoreLocation
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
let location = locationManager.location!.coordinate
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
<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>
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(','));
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
};
// 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();
});