Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add waypoints #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;

import java.util.ArrayList;

/**
* Created by ocittwo on 11/14/16.
*
Expand Down Expand Up @@ -32,6 +34,13 @@ public DrawRouteMaps draw(LatLng origin, LatLng destination, GoogleMap googleMap
return instance;
}

public DrawRouteMaps draw(LatLng origin, LatLng destination, ArrayList<LatLng> waypoints, GoogleMap googleMap) {
String url_route = FetchUrl.getUrlWithWayPoints(origin, destination,waypoints);
DrawRoute drawRoute = new DrawRoute(googleMap);
drawRoute.execute(new String[]{url_route});
return instance;
}

public static Context getContext() {
return instance.context;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.google.android.gms.maps.model.LatLng;

import java.util.ArrayList;

/**
* Created by ocittwo on 11/14/16.
*
Expand All @@ -19,4 +21,18 @@ public static String getUrl(LatLng origin, LatLng dest) {
String output = "json";
return "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters;
}

public static String getUrlWithWayPoints(LatLng origin, LatLng dest, ArrayList<LatLng> waypoints) {
String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
String str_waypoints = "waypoints=optimize:true|";
for(LatLng latLng : waypoints){
str_waypoints = str_waypoints + "via:" + latLng.latitude + "," + latLng.longitude + "|";
}
String sensor = "sensor=false";
String transit = "transit=walking";
String parameters = str_origin + "&" + str_dest + "&" + str_waypoints + "&" + sensor + "&" + transit;
String output = "json";
return "https://maps.googleapis.com/maps/api/directions/" + output + "?" + parameters;
}
}