i'm trying incorporate feature in app give user walking directions location via mapkit. i've seen on maps app don't know how myself. got directions car stumped on how walking. have far:
func getdirections(){ let request = mkdirectionsrequest() request.source = mkmapitem.mapitemforcurrentlocation() request.destination = destination request.requestsalternateroutes = false let directions = mkdirections(request: request) directions.calculatedirectionswithcompletionhandler { (response, error) in if error != nil { print("error \(error)") } else { //self.displayrout(response) var overlays = self.mapview.overlays self.mapview.removeoverlays(overlays) route in response!.routes as! [mkroute] { self.mapview.addoverlay(route.polyline, level: mkoverlaylevel.aboveroads) var instructionnumber = 0 next in route.steps { instructionnumber += 1 print(next.instructions) } } } }
also don't want have open maps app up. need find route inside app.
mkdirectionsrequest
has transporttype property. add right after create transport request:
let request = mkdirectionsrequest() request.transporttype = .walking
(i've never tried walking directions before, found in xcode docs in less 30 seconds. learn way around xcode "documentation , api reference" in menu. contains wealth of information.)
Comments
Post a Comment