Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-alexander committed Jan 7, 2016
2 parents 7f2b185 + 9f4f19e commit 7dfd87b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Grab via Maven:
<dependency>
<groupId>com.github.jd-alexander</groupId>
<artifactId>library</artifactId>
<version>1.0.7</version>
<version>1.0.9</version>
</dependency>
```
or Gradle:
```groovy
compile 'com.github.jd-alexander:library:1.0.7'
compile 'com.github.jd-alexander:library:1.0.9'
```

Usage
Expand All @@ -46,11 +46,15 @@ To calculate the route you simply instantiate a Routing object and trigger the e
.travelMode(/* Travel Mode */)
.withListener(/* Listener that delivers routing results.*/)
.waypoints(/*waypoints*/)
.key(/*api key for quota management*/)
.build();
routing.execute();

```




actual code
``` java
start = new LatLng(18.015365, -77.499382);
Expand All @@ -66,15 +70,11 @@ actual code

.....

@Override
public void onRoutingSuccess(PolylineOptions mPolyOptions)
{
PolylineOptions polyoptions = new PolylineOptions();
polyoptions.color(Color.BLUE);
polyoptions.width(10);
polyoptions.addAll(mPolyOptions.getPoints());
map.addPolyline(polyoptions);
}
@Override
public void onRoutingSuccess(ArrayList<Route> route, int shortestRouteIndex)
{
//code to add route to map here. See sample app for more details.
}
```


Expand Down Expand Up @@ -105,7 +105,7 @@ Contributors
License
--------

Copyright 2015 Joel Dean
Copyright 2016 Joel Dean

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
public abstract class AbstractRouting extends AsyncTask<Void, Void, ArrayList<Route>> {
protected ArrayList<RoutingListener> _aListeners;

protected static final String DIRECTIONS_API_URL = "http://maps.googleapis.com/maps/api/directions/json?";
protected static final String DIRECTIONS_API_URL = "https://maps.googleapis.com/maps/api/directions/json?";

public enum TravelMode {
BIKING("bicycling"),
Expand Down
14 changes: 14 additions & 0 deletions library/src/main/java/com/directions/route/Routing.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Routing extends AbstractRouting {
private final int avoidKinds;
private final boolean optimize;
private final String language;
private final String key;

private Routing(Builder builder) {
super(builder.listener);
Expand All @@ -27,6 +28,7 @@ private Routing(Builder builder) {
this.optimize = builder.optimize;
this.alternativeRoutes = builder.alternativeRoutes;
this.language = builder.language;
this.key = builder.key;
}

protected String constructURL () {
Expand Down Expand Up @@ -83,6 +85,11 @@ protected String constructURL () {
stringBuilder.append("&language=").append(language);
}

// API key
if(key != null) {
stringBuilder.append("&key=").append(key);
}

return stringBuilder.toString();
}

Expand All @@ -95,6 +102,7 @@ public static class Builder {
private RoutingListener listener;
private boolean optimize;
private String language;
private String key;

public Builder () {
this.travelMode = TravelMode.DRIVING;
Expand All @@ -104,6 +112,7 @@ public Builder () {
this.listener = null;
this.optimize = false;
this.language = null;
this.key = null;
}

public Builder travelMode (TravelMode travelMode) {
Expand Down Expand Up @@ -144,6 +153,11 @@ public Builder language (String language) {
return this;
}

public Builder key(String key) {
this.key = key;
return this;
}

public Builder withListener (RoutingListener listener) {
this.listener = listener;
return this;
Expand Down

0 comments on commit 7dfd87b

Please sign in to comment.