How to invoke iPhone Maps for Directions with Current Location as Start Address

后端 未结 16 1678
一整个雨季
一整个雨季 2020-12-02 03:53

I know it\'s possible to start the iPhone maps application by calling openURL on a google maps URL with parameters saddr and daddr wit

16条回答
  •  清歌不尽
    2020-12-02 04:42

    My suggestion would be using OpenInGoogleMaps-iOS as this is an up to date choice (by November 2015), it supports cocoa pods installation and you are ready to go in a few clicks.

    Install using: pod "OpenInGoogleMaps"

    Require in header file using: #import "OpenInGoogleMapsController.h"

    Sample code below:

    /*In case the user does NOT have google maps, then apple maps shall open*/
    [OpenInGoogleMapsController sharedInstance].fallbackStrategy = kGoogleMapsFallbackAppleMaps;    
    
    /*Set the coordinates*/
    GoogleMapDefinition *definition = [[GoogleMapDefinition alloc] init];   
    CLLocationCoordinate2D metsovoMuseumCoords;     //coordinates struct
    metsovoMuseumCoords.latitude = 39.770598;
    metsovoMuseumCoords.longitude = 21.183215;
    definition.zoomLevel = 20;
    definition.center = metsovoMuseumCoords;        //this will be the center of the map
    
    /*and here we open the map*/
    [[OpenInGoogleMapsController sharedInstance] openMap:definition];       
    

提交回复
热议问题