Giter Club home page Giter Club logo

pxgoogledirections's Introduction

PXGoogleDirections

Google Directions API SDK for iOS, entirely written in Swift.

Cocoapods Cocoapods Cocoapods Swift

CocoaPods CocoaPods CocoaPods

GitHub stars GitHub forks GitHub watchers Twitter Follow

Features

  • Supports all features from the Google Directions API as of November 2016 (see here for a full list: https://developers.google.com/maps/documentation/directions)
  • Supports "open in Google Maps app", both for specific locations and directions request
    • also supports the callback feature to get the user back to your app when he's done in Google Maps
    • in case the Google Maps app is not installed, also supports fallback to the built-in Apple Maps app
  • Available both with modern, Swift-style completion blocks, or Objective-C-style delegation patterns
  • Queries are made over HTTPS
  • JSON is used behind the scenes to help reduce the size of the responses
  • Available through CocoaPods
  • V1.3 is fully compatible with Swift 3 and Google Maps iOS SDK V2+

New in V1.3

  • Full Swift 3 support
  • Full Google Maps iOS SDK 2.0+ support
  • Added a trafficModel property on the PXGoogleDirections class to match Google's one in the API (recently added); it works only for driving routes, and when a departure date is specified
  • Fixed a bug where drawing a route would only draw a basic, rough representation of it taken from the route object; now there is an option for drawing a detailed route in the drawOnMap method of the PXGoogleDirectionsRoute class
  • Other small bug fixes

Installation

From Cocoapods

To use PXGoogleDirections in your project add the following 'Podfile' to your project:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.1'

pod 'PXGoogleDirections'

use_frameworks!

Then run the following command from the Terminal:

pod install

Now, from your code, you should be able to simply import the module like this:

import PXGoogleDirections

You might run into issues if you mix up PXGoogleDirections with the Google Maps iOS SDK in your app. If you do so, please check the "In case of problems" paragraph below, and do not hesitate to contact me and describe your issue if you require assistance!

From source

  • Clone the repository
  • Add the whole PXGoogleDirections project to your own Xcode project
  • Add a dependency between the two projects and build

Usage

Quick-start in two lines of Swift code:

  1. Create an API object:
let directionsAPI = PXGoogleDirections(apiKey: "<insert your Google API key here>",
    from: PXLocation.CoordinateLocation(CLLocationCoordinate2DMake(37.331690, -122.030762)),
    to: PXLocation.SpecificLocation("Googleplex", "Mountain View", "United States"))
  1. Run the Directions request:
directionsAPI.calculateDirections({ response in
 switch response {
  case let .error(_, error):
   // Oops, something bad happened, see the error object for more information
   break
  case let .success(request, routes):
   // Do your work with the routes object array here
   break
 }
})

See "Documentation" below for more information on the available properties and response data.

Requirements

  • Runs on iOS 8.1 at least, or above.
  • Compatible with Swift 3 / Xcode 8 and later.
    • Please use v1.2.3 if you need compatibility with a previous version of Swift.
  • The SDK depends on the official Google Maps SDK for iOS (more information here: Google Maps iOS SDK)

Documentation

The SDK provides an integrated documentation within Xcode, with full autocomplete support.

To help getting you started, a sample project is also available in the "Sample" subfolder of this repository.

It is designed to demo the main features of both the API and the SDK.

In case of problems

Since V1.3, PXGoogleDirections uses Google's latest branch of Google Maps iOS SDK, which has now been split into smaller, more modular frameworks. PXGoogleDirections has a dependency with three of them:

  • GoogleMapsCore
  • GoogleMapsBase
  • GoogleMaps

The Google Places iOS SDK is not required.

If your app also requires the Google Maps iOS SDK, you might run into troubles because of conflicts with the bundled Google Maps iOS SDK in the Cocoapod. Providing Cocoapods frameworks with static framework dependencies like Google Maps is a real pain and there is no simple, straightforward solution I'm aware of, unfortunately.

If you happen to face these problems, please try to do the following:

Credit

License

The PXGoogleDirections SDK is licensed under the New BSD license. (see LICENSE for more information.)

Contact

Don't hesitate to drop me a line on Github, Twitter, Stack Overflow, or by email:

pxgoogledirections's People

Contributors

poulpix avatar dentelezhkin avatar

Watchers

James Cloos avatar  avatar

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.