Code Monkey home page Code Monkey logo

directionssdk's Introduction

Directions SDK

Build Status Download

What is it?

It's a library written in Kotlin to utilize Google Directions API calls and convert response to data classes.

How do I use it?

Add dependency

allprojects {
	repositories {
		...
		maven { url 'https://dl.bintray.com/rozkminiacz/Directions-Android-SDK' }
	}
}
implementation : 'me.rozkmin.directions:core:1.0'	

Create instance of DirectionsApiClient:

class AnotherBoringMapActivity : Activity(){
    val directions : Directions by lazy {
        DirectionsSdk(getString(R.string.google_directions_key))
    }
}

Transit options

You can specify severalDirections API request parameters:

val transitOptions = TransitOptions(
                mode = MODE.WALKING, 
                whatToAvoidArray = arrayOf(AVOID.FERRIES, AVOID.HIGHWAYS))

Request route between points

class AnotherBoringMapActivity : Activity(){
    fun getSuggestions(from: LatLng, to: LatLng){
            directions.getSuggestions(
                    origin = Position(from.latitude, from.longitude),
                    destination = Position(to.latitude, from.longitude))
                    .subscribe({ t : GeocodedResponse ->
                        //process routes
                    },{
                        //error
                    })
        }
}

Retrieve route steps:

fun processData(geocodedResponse: GeocodedResponse){
    val stepStart: Position = geocodedResponse.routes[0].legs[0].steps[0].start
    val stepEnd: Position = geocodedResponse.routes[0].legs[0].steps[0].end
}

Make use of detailed polyline

fun processData(geocodedResponse: GeocodedResponse){
        val positions: List<Position> = geocodedResponse.routes[0].overviewPolyline.getDetailedWaypointsPositions()
}

I want to improve this library!

Sure! Pull requests are welcome! Any reasonable extension will be added.

Tools used:

directionssdk's People

Contributors

rozkminiacz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

directionssdk's Issues

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.