Giter VIP home page Giter VIP logo

turnbyturndirectionssample's Introduction

TurnByTurnDirectionsSample

Turn-by-Turn Directions Sample App

screen shot screen shot screen shot

##Requirement iOS6.0 or later

##About this sample app It is very easy to call Turn-by-Turn Directions Navigation Map.

This sample app is explain how to wake up the map from your apps.

First, you should make MKMapItem by using mapItemForCurrentLocationmethod.

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _currentItem = [MKMapItem mapItemForCurrentLocation];
	// Do any additional setup after loading the view, typically from a nib.
}

Second, you should make destination object and set as mapItems to openMapsWithItems:launchOptions: method.

- (IBAction)onDestinationButton:(id)sender {
    
    UIButton *button = (UIButton *)sender;
    int destination = button.tag;
    switch (destination) {
        case 11111:
        {
            //Yokohama landmark tower 35.454569, 139.63142
            CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(35.454569, 139.63142);
            MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:coords addressDictionary:nil];
            _destinationItem = [[MKMapItem alloc]initWithPlacemark:place];
            _destinationItem.name = @"Yokohama landmark tower";
        }
            break;
        case 22222:
        {
            //Bashamichi station 35.450135, 139.636175
            CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(35.450135, 139.636175);
            MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:coords addressDictionary:nil];
            _destinationItem = [[MKMapItem alloc]initWithPlacemark:place];
            _destinationItem.name = @"Bashamichi station";
        }
            break;
            
        case 33333:
        {
            //Yokohama stadium 35.443336, 139.64
            CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(35.443336, 139.64);
            MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:coords addressDictionary:nil];
            _destinationItem = [[MKMapItem alloc]initWithPlacemark:place];
            _destinationItem.name = @"Yokohama stadium";
        }
            
            break;
        default:
            break;
    }
    NSDictionary *options = @{
                              MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,
                              MKLaunchOptionsMapTypeKey:[NSNumber numberWithInteger:MKMapTypeSatellite],
                              MKLaunchOptionsShowsTrafficKey:@YES
                              };
    
    [MKMapItem openMapsWithItems:@[_currentItem, _destinationItem] launchOptions:options];
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.