mapbox/mapbox-navigation-ios: Turn-by-turn ... - GitHub
文章推薦指數: 80 %
Go to your Mapbox account dashboard and create an access token that has the DOWNLOADS:READ scope. · In Xcode, go to File ‣ Swift Packages ‣ Add Package ... Skiptocontent {{message}} mapbox / mapbox-navigation-ios Public Notifications Fork 259 Star 744 Turn-by-turnnavigationlogicandUIinSwiftoniOS docs.mapbox.com/ios/navigation/ License Viewlicense 744 stars 259 forks Star Notifications Code Issues 168 Pullrequests 22 Discussions Wiki Security Insights More Code Issues Pullrequests Discussions Wiki Security Insights Thiscommitdoesnotbelongtoanybranchonthisrepository,andmaybelongtoaforkoutsideoftherepository. main Branches Tags Couldnotloadbranches Nothingtoshow {{refName}} default Couldnotloadtags Nothingtoshow {{refName}} default 248 branches 174 tags Code Latestcommit 1ec5 v2.5.0-beta.3 … f720578 May7,2022 v2.5.0-beta.3 f720578 Gitstats 6,904 commits Files Permalink Failedtoloadlatestcommitinformation. Type Name Latestcommitmessage Committime .circleci .github .tx Example MapboxNavigation-SPM.xcodeproj MapboxNavigation.xcodeproj Sources Tests docs scripts .base_api .gitattributes .gitignore .gitmodules .swiftlint.yml CHANGELOG.md CONTRIBUTING.md Cartfile Cartfile.private Cartfile.resolved Gemfile Gemfile.lock LICENSE.md MapboxCoreNavigation.podspec MapboxNavigation.podspec Package.resolved Package.swift README.md codecov.yml custom-navigation.md taginfo.json Viewcode MapboxNavigationSDKforiOS Features Documentation Requirements Installation UsingSwiftPackageManager UsingCocoaPods UsingCarthage Configuration Examples Customization Styling Startingfromscratch Contributing License README.md MapboxNavigationSDKforiOS MapboxNavigationgivesyouallthetoolsyouneedtoaddturn-by-turnnavigationtoyouriOSapplication. Getupandrunninginafewminuteswithourdrop-inturn-by-turnnavigationNavigationViewController,orbuildacompletelycustomturn-by-turnnavigationappwithourcorecomponentsforroutingandnavigation. Features Afull-fledgedturn-by-turnnavigationUIforiPhone,iPad,andCarPlaythat’sreadytodropintoyourapplication Professionallydesignedmapstylesfordaytimeandnighttimedriving Worldwidedriving,cycling,andwalkingdirectionspoweredbyopendataanduserfeedback Trafficavoidanceandproactivereroutingbasedoncurrentconditionsinover55countries Natural-soundingturninstructionspoweredbyAmazonPolly(noconfigurationneeded) Supportforovertwodozenlanguages Documentation Requirements TheMapboxNavigationSDKandCoreNavigationarecompatiblewithapplicationswritteninSwift5inXcode12.4andabove.TheMapboxNavigationandMapboxCoreNavigationframeworksrunoniOS11.0andabove. TheMapboxNavigationSDKisalsoavailableforAndroid. Installation UsingSwiftPackageManager ToinstalltheMapboxNavigationframeworkinanapplicationusingSwiftPackageManager: GotoyourMapboxaccountdashboardandcreateanaccesstokenthathastheDOWNLOADS:READscope.PLEASENOTE:ThisisnotthesameasyourproductionMapboxAPItoken.MakesuretokeepitprivateanddonotinsertitintoanyInfo.plistfile.Createafilenamed.netrcinyourhomedirectoryifitdoesn’talreadyexist,thenaddthefollowinglinestotheendofthefile: machineapi.mapbox.com loginmapbox passwordPRIVATE_MAPBOX_API_TOKEN wherePRIVATE_MAPBOX_API_TOKENisyourMapboxAPItokenwiththeDOWNLOADS:READscope. InXcode,gotoFile‣SwiftPackages‣AddPackageDependency. Enterhttps://github.com/mapbox/mapbox-navigation-ios.gitasthepackagerepositoryandclickNext. SetRulestoVersion,UptoNextMajor,andenter2.3.0astheminimumversionrequirement.ClickNext. ToinstalltheMapboxNavigationframeworkinanotherpackageratherthananapplication,runswiftpackageinittocreateaPackage.swift,thenaddthefollowingdependency: //Lateststablerelease .package(name:"MapboxNavigation",url:"https://github.com/mapbox/mapbox-navigation-ios.git",from:"2.3.0") //Latestprerelease .package(name:"MapboxNavigation",url:"https://github.com/mapbox/mapbox-navigation-ios.git",.exact("2.5.0-beta.3")) UsingCocoaPods ToinstalltheMapboxNavigationframeworkusingCocoaPods: GotoyourMapboxaccountdashboardandcreateanaccesstokenthathastheDOWNLOADS:READscope.PLEASENOTE:ThisisnotthesameasyourproductionMapboxAPItoken.MakesuretokeepitprivateanddonotinsertitintoanyInfo.plistfile.Createafilenamed.netrcinyourhomedirectoryifitdoesn’talreadyexist,thenaddthefollowinglinestotheendofthefile: machineapi.mapbox.com loginmapbox passwordPRIVATE_MAPBOX_API_TOKEN wherePRIVATE_MAPBOX_API_TOKENisyourMapboxAPItokenwiththeDOWNLOADS:READscope. CreateaPodfilewiththefollowingspecification: #Lateststablerelease pod'MapboxCoreNavigation','~>2.4' pod'MapboxNavigation','~>2.4' #Latestprerelease pod'MapboxCoreNavigation',:git=>'https://github.com/mapbox/mapbox-navigation-ios.git',:tag=>'v2.5.0-beta.3' pod'MapboxNavigation',:git=>'https://github.com/mapbox/mapbox-navigation-ios.git',:tag=>'v2.5.0-beta.3' Runpodrepoupdate&&podinstallandopentheresultingXcodeworkspace. UsingCarthage ToinstalltheMapboxNavigationframeworkusingCarthagev0.38orabove: GotoyourMapboxaccountdashboardandcreateanaccesstokenthathastheDOWNLOADS:READscope.PLEASENOTE:ThisisnotthesameasyourproductionMapboxAPItoken.MakesuretokeepitprivateanddonotinsertitintoanyInfo.plistfile.Createafilenamed.netrcinyourhomedirectoryifitdoesn’talreadyexist,thenaddthefollowinglinestotheendofthefile: machineapi.mapbox.com loginmapbox passwordPRIVATE_MAPBOX_API_TOKEN wherePRIVATE_MAPBOX_API_TOKENisyourMapboxAPItokenwiththeDOWNLOADS:READscope. (Optional)ClearyourCarthagecaches: rm-rf~/Library/Caches/carthage/~/Library/Caches/org.carthage.CarthageKit/binaries/{MapboxCommon-ios,MapboxNavigationNative,mapbox-ios-sdk-dynamic} CreateaCartfilewiththefollowingdependency: #Lateststablerelease github"mapbox/mapbox-navigation-ios"~>2.4 #Latestprerelease github"mapbox/mapbox-navigation-ios""v2.5.0-beta.3" Runcarthagebootstrap--platformiOS--use-xcframeworks--cache-builds--use-netrc. FollowtherestofCarthage’siOSintegrationinstructions.Yourapplicationtarget’sEmbedFrameworksbuildphaseshouldincludeMapboxCoreNavigation.xcframework,MapboxNavigationNative.xcframework,andMapboxCommon.xcframework. MapboxNavigationnolongersupportsCarthageasofv2.0.0-alpha.1.However,ifyouarebuildingauserinterfacefromscratch,youcaninstalljusttheMapboxCoreNavigationframeworkusingCarthage. Configuration MapboxAPIsandvectortilesrequireaMapboxaccountandAPIaccesstoken.Intheprojecteditor,selecttheapplicationtarget,thengototheInfotab.Underthe“CustomiOSTargetProperties”section,setMBXAccessTokentoyouraccesstoken.YoucanobtainanaccesstokenfromtheMapboxaccountpage. InorderfortheSDKtotracktheuser’slocationastheymovealongtheroute,setNSLocationWhenInUseUsageDescriptionto: Showsyourlocationonthemapandhelpsimprovethemap. UsersexpecttheSDKtocontinuetotracktheuser’slocationanddeliveraudibleinstructionsevenwhileadifferentapplicationisvisibleorthedeviceislocked.GototheSigning&Capabilitiestab.UndertheBackgroundModessection,enable“Audio,AirPlay,andPictureinPicture”and“Locationupdates”.(Alternatively,addtheaudioandlocationvaluestotheUIBackgroundModesarrayintheInfotab.) NowimporttherelevantmodulesandpresentanewNavigationViewController.Youcanalsopushtoanavigationviewcontrollerfromwithinastoryboardifyourapplication’sUIislaidoutinInterfaceBuilder. importMapboxDirections importMapboxCoreNavigation importMapboxNavigation //Definetwowaypointstotravelbetween letorigin=Waypoint(coordinate:CLLocationCoordinate2D(latitude:38.9131752,longitude:-77.0324047),name:"Mapbox") letdestination=Waypoint(coordinate:CLLocationCoordinate2D(latitude:38.8977,longitude:-77.0365),name:"WhiteHouse") //Setoptions letrouteOptions=NavigationRouteOptions(waypoints:[origin,destination]) //RequestarouteusingMapboxDirections Directions.shared.calculate(routeOptions){[weakself](session,result)in switchresult{ case.failure(leterror): print(error.localizedDescription) case.success(letresponse): guardletstrongSelf=selfelse{ return } //PassthegeneratedrouteresponsetothetheNavigationViewController letviewController=NavigationViewController(for:response,routeIndex:0,routeOptions:routeOptions) viewController.modalPresentationStyle=.fullScreen strongSelf.present(viewController,animated:true,completion:nil) } } ConsulttheAPIreferenceforfurtherdetails. Examples TheAPIreferenceincludesexamplecodeforaccomplishingcommontasks.Youcanruntheseexamplesaspartofthenavigation-ios-examplesproject. ThisrepositoryalsocontainsatestbedapplicationthatexercisesavarietyofnavigationSDKfeatures.Seethecontributingguideforinstructionsoninstallingandrunningthisapplication. Customization Styling Youcancustomizetheappearanceinordertoblendinwiththerestofyourapp.CheckoutDayStyle.swiftforallstyleableelements. classCustomStyle:DayStyle{ requiredinit(){ super.init() mapStyleURL=URL(string:"mapbox://styles/mapbox/satellite-streets-v9")! styleType=.nightStyle } overridefuncapply(){ super.apply() BottomBannerView.appearance().backgroundColor=.orange } } theninitializeNavigationViewControllerwithyourstyleorstyles: letnavigationOptions=NavigationOptions(styles:[CustomStyle()]) NavigationViewController(for:routeResponse,routeIndex:routeIndex,routeOptions:routeOptions,navigationOptions:navigationOptions) Startingfromscratch Ifyourapplicationneedssomethingtotallycustom,suchasavoice-onlyexperienceoranunconventionaluserinterface,consulttheCoreNavigationinstallationguide. Contributing Wewelcomefeedbackandcodecontributions!PleaseseeCONTRIBUTING.mdfordetails. License TheMapboxNavigationSDKforiOSisreleasedundertheMapboxTermsofService.SeeLICENSE.mdfordetails. About Turn-by-turnnavigationlogicandUIinSwiftoniOS docs.mapbox.com/ios/navigation/ Topics swift ios navigation directions swift-package-manager turn-by-turn-navigation guidance amazon-polly polly carplay Resources Readme License Viewlicense Stars 744 stars Watchers 96 watching Forks 259 forks Releases 171 v2.4.1 Latest May5,2022 +170releases Contributors63 +52contributors Languages Swift 99.0% Other 1.0% Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.
延伸文章資訊
- 1mapbox/mapbox-navigation-ios: Turn-by-turn ... - GitHub
Go to your Mapbox account dashboard and create an access token that has the DOWNLOADS:READ scope....
- 2Releases · mapbox/mapbox-gl-native-ios - GitHub
Interactive, thoroughly customizable maps for iOS powered by vector tiles and OpenGL - Releases ·...
- 3OrdnanceSurvey/mapbox-ios-sdk - GitHub
Mapbox iOS SDK. Carthage compatible. Based on the Route-Me iOS map library (Alpstein fork) with M...
- 4mapbox-common-ios - GitHub
Contribute to mapbox/mapbox-common-ios development by creating an account on GitHub. ... MapboxCo...
- 5Mapbox - GitHub
Mapbox is the location data platform for mobile and web applications. ... Interactive, thoroughly...