Last active
October 17, 2017 06:34
-
-
Save codephillip/2edbed76d625ee552db9f9fdf1c3f31b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://maps.googleapis.com/maps/api/directions/json?origin=0.3181614,32.5736069&destination=0.3184610990987622,32.55381792783737&sensor=false&mode=driving | |
// Method 1 | |
String MAP_BASE_URL = "https://maps.googleapis.com/maps/api/directions/json?"; | |
Uri.Builder builtUri = Uri.parse(MAP_BASE_URL) | |
.buildUpon() | |
.appendQueryParameter("origin", origin.latitude + "," + origin.longitude) | |
.appendQueryParameter("destination", dest.latitude + "," + dest.longitude) | |
.appendQueryParameter("sensor", "false") | |
.appendQueryParameter("mode", "driving"); | |
String url = builtUri.build().toString(); | |
// Method 2 | |
Uri.Builder builder = new Uri.Builder(); | |
builder.scheme("https") | |
.authority("maps.googleapis.com") | |
.appendPath("maps") | |
.appendPath("api") | |
.appendPath("directions") | |
.appendPath("json") | |
.appendQueryParameter("origin", origin.latitude + "," + origin.longitude) | |
.appendQueryParameter("destination", dest.latitude + "," + dest.longitude) | |
.appendQueryParameter("sensor", "false") | |
.appendQueryParameter("mode", "driving"); | |
String url = builder.build().toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment