GithubHelp home page GithubHelp logo

trioblack / google-directions-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jd-alexander/google-directions-android

0.0 2.0 0.0 1.49 MB

This project allows you to calculate the route between two locations and displays it on a map.

Home Page: http://joeldeandev.com

License: MIT License

Java 100.00%

google-directions-android's Introduction

Google-Directions-Android Bitdeli Badge

This project allows you to calculate the direction between two locations and display the route on a map based on the classes created by Hesham Saeed in this post.

Sample

A map with route overlay.

Example Image

Installation

The sample project requires:

  • The library project
  • Google Play services SDK (bundled with project)
  • android-support-v4-jar (bundled with project)
  • Android dependencies installed on your development machine.

Usage

Google Directions Android(the library folder) is presented as an Android library project. You can include this project by referencing it as a library project in Eclipse or ant.

For the library project a reference has to be done to the Google Play Services Lib project that contains the Google Maps Android API v2 dependencies.

To calculate the route and display it on the map you will need to run an async task that is present in the library.

N.B Ensure that the google play servicers jar is attached to the Google Play Services lib project.

*You can execute the task in this manner. ( See the example for more details on the exact implementation)

        Routing routing = new Routing(/* Travel Mode */);
        routing.registerListener(/* Listener that delivers routing results.*/);
        routing.execute(/*LatLng(start)*/, /*LatLng(destination)*/);
        

actual code

        start = new LatLng(18.015365, -77.499382);
        end = new LatLng(18.012590, -77.500659);
        
        Routing routing = new Routing(Routing.TravelMode.WALKING);
        routing.registerListener(this);
        routing.execute(start, end);
        
        .....
        
      @Override
      public void onRoutingSuccess(PolylineOptions mPolyOptions) 
      {
        PolylineOptions polyoptions = new PolylineOptions();
        polyoptions.color(Color.BLUE);
        polyoptions.width(10);
        polyoptions.addAll(mPolyOptions.getPoints());
        map.addPolyline(polyoptions);
      }

*The library is bundled with start and end pushpins of various colours, check the example included or just have a look in the res folder.

Known Issues

*If after importing the project(s) you get an error stating that no resource was found that matches a given name, just clean the project.

*Ensure that the Google Play Services SDK is attached to the libary project and that all references and values are in your manifest.

*For the example project it needs android-support-v4-jar due to use of the elements from the support library.

*If the route is not being displayed then type "Routing" in your log cat to see the potential error messages from the library.

*The color is of type int, its not an actual color. Just type Color. and wait for the intellisense the to suggest the colors.

Contribution

Please fork repository and contribute using pull requests.

Any contributions, large or small, major features, bug fixes, additional language translations, unit/integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed.

Contributors

Cyrille Berliat

Developed By

google-directions-android's People

Contributors

jd-alexander avatar licryle avatar ksarmalkar avatar bitdeli-chef avatar

Watchers

James Cloos avatar AGC 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.