Related
if I point google Maps to a location [-20.1419057374276,-157.33203817679]
and then carry out a nearby search for "tour operator" I get, in the case of that location, 9 results https://www.google.com/maps/search/Tour+operator/#-21.2333094,-159.7948598,14z
if I use Google Places API (in this case in R using httr:GET - I have tried googleway also) I do not get any results returned (status:"ZERO_RESULTS"):
res.wild<-GET(paste("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=",paste(centers$lat[i],centers$lon[i],sep=","),"&radius=35000&keyword=tour+operator&key=",myKey,sep=""))
where centers$lat[i],centers$lon[i] is -20.1419057374276,-157.33203817679
I used to use the radar search which is no longer available but seemed to return results consistent with a direct search on google maps. Going through the documentation, I cannot see from where this discrepancy come.
Anyone has any idea?
thanks!
The coordinates shown in the URL of Google Maps are not reliable as they take zoom into account. If you want to get exact coordinates, use other methods such as Geocoding.
The -20.1419057374276,-157.33203817679 coordinate points to Mauke, Cook Islands: https://developers.google.com/maps/documentation/utils/geocoder/#q%3D-20.141906%252C-157.332038
If you want to get nearby places from Rarotonga, Cook Islands, then you can e.g. use -21.229237,-159.776349 instead: https://developers.google.com/maps/documentation/utils/geocoder/#q%3D-21.229237%252C-159.776349
Try this request using the above coordinates:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-21.229237,-159.776349&radius=35000&keyword=tour+operator&key=YOUR_KEY
The output is close to what you get in Google Maps:
{
"html_attributions" : [],
"results" : [
{
"geometry" : {
"location" : {
"lat" : -21.2573049,
"lng" : -159.7311111
},
"viewport" : {
"northeast" : {
"lat" : -21.25565152010728,
"lng" : -159.7299870701073
},
"southwest" : {
"lat" : -21.25835117989272,
"lng" : -159.7326867298927
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "d54699b006411b5a5f9450ee2b30e88ad7deec44",
"name" : "Captain Tamas Lagoon Cruizes",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 645,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/102745446521532412613\"\u003eCaptain Tamas Lagoon Cruises\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAA6O-c8lb1bdh75I9dWRqjmTZanPhSx8LgNlVxR9ZMtoLkQMQ0uzSMGFr_xtfwdID9wPS2DlNIXO4aqHc_eVGzjDjPNzLyO_f8YvIp6gaP3xoYGRfKoOb_aZpKOqS2INnMEhA75QSRQC4FQnM8sXketTROGhRC1SgaNX6Hg1S6PIxlVQEOiVM4CQ",
"width" : 859
}
],
"place_id" : "ChIJmSbDLojTV3EROL5C9_iW6kg",
"plus_code" : {
"compound_code" : "P7V9+3H Ngatangiia District, Cook Islands",
"global_code" : "53C2P7V9+3H"
},
"rating" : 4.8,
"reference" : "ChIJmSbDLojTV3EROL5C9_iW6kg",
"scope" : "GOOGLE",
"types" : [ "travel_agency", "point_of_interest", "establishment" ],
"user_ratings_total" : 102,
"vicinity" : "Muri Beach, Muri"
},
{
"geometry" : {
"location" : {
"lat" : -21.258145,
"lng" : -159.732045
},
"viewport" : {
"northeast" : {
"lat" : -21.25663512010728,
"lng" : -159.7310816201073
},
"southwest" : {
"lat" : -21.25933477989272,
"lng" : -159.7337812798927
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "354b255213a808490880fe1b9551d0f442aae382",
"name" : "Koka Lagoon Cruises",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 3024,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/103124684904518750526\"\u003eHuong Tran\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAbNLjafLjIMjmUaJ-jilVZuJfWt79C_IoPEC-epFVSSSSlwQLo9_RMVRWl_dAAx4naup6P8aCr-F-TtTtzWpB_cI0-B1RbBcbp4mIvGxqLQvBeX6DWKi-gaT1UjsfKhG4EhDDBz4JWPKmCx4Mq3hiUv1iGhTKRpHYORs6lj-VYV-bqwTo6VFw0g",
"width" : 4032
}
],
"place_id" : "ChIJu4ZfKXbUV3ERrKo9dhOCJiI",
"plus_code" : {
"compound_code" : "P7R9+P5 Ngatangiia District, Cook Islands",
"global_code" : "53C2P7R9+P5"
},
"rating" : 4.9,
"reference" : "ChIJu4ZfKXbUV3ERrKo9dhOCJiI",
"scope" : "GOOGLE",
"types" : [ "point_of_interest", "establishment" ],
"user_ratings_total" : 67,
"vicinity" : "Muri Beach, Rarotonga"
},
{
"geometry" : {
"location" : {
"lat" : -21.2204492,
"lng" : -159.8285893
},
"viewport" : {
"northeast" : {
"lat" : -21.21907502010728,
"lng" : -159.8273637201073
},
"southwest" : {
"lat" : -21.22177467989272,
"lng" : -159.8300633798927
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "6ca2b13851e47e4474fd197888d503d352de2f15",
"name" : "Tik-e Tours",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 4032,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/117619328803821181982\"\u003eA Google User\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAdq12AeQCjoIpk09GCOx-laja1_iJ2Vzgnonu1quJ0bIzdOjV6YOvBHYoJT8hXwlyaUGB5C5o14HS3i-FUdwOuln7OFsY56r-bguBuQGV5_ukiyNHrCiCeRU5M7PhaLo2EhAfer7M013sz3i2uVsxTEfSGhQqWr9yhhB8UKcNGps3kOxCFcQa3A",
"width" : 3024
}
],
"place_id" : "ChIJGe7bPVnQV3ERHI7vgH-Ou3c",
"plus_code" : {
"compound_code" : "Q5HC+RH Arorangi District, Cook Islands",
"global_code" : "53C2Q5HC+RH"
},
"rating" : 4.9,
"reference" : "ChIJGe7bPVnQV3ERHI7vgH-Ou3c",
"scope" : "GOOGLE",
"types" : [ "point_of_interest", "establishment" ],
"user_ratings_total" : 10,
"vicinity" : "Arorangi District"
},
{
"geometry" : {
"location" : {
"lat" : -21.2655311,
"lng" : -159.7819558
},
"viewport" : {
"northeast" : {
"lat" : -21.26411742010728,
"lng" : -159.7805932701072
},
"southwest" : {
"lat" : -21.26681707989272,
"lng" : -159.7832929298927
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "91cdd05c5d95d60981a890fd54886ebcad4b8ba9",
"name" : "Snorkel Cook Islands",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 2304,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/112866284698762632354\"\u003eFe'ena Syme Buchanan\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAd8e9zm-Wsa8hR-YkjI-bbLB_N_qJ9k5TOaYAjiyYhrHUJjQkdC9DmFc3RZVnQKpcS-QY7A3AtJPIG5OLH8dNSAwiQUB2tYmB-CMD6ZDRUSqqBpa3P_p2y9jc2sv9Lqd4EhDJooK75NFPEz0k_YsX38WMGhS1znNvtNWs-xwCg1OL0sF1JRHRZQ",
"width" : 3456
}
],
"place_id" : "ChIJKTe2bjLXV3ERHUapU18Vydg",
"plus_code" : {
"compound_code" : "P6M9+Q6 Takitumu District, Cook Islands",
"global_code" : "53C2P6M9+Q6"
},
"rating" : 5,
"reference" : "ChIJKTe2bjLXV3ERHUapU18Vydg",
"scope" : "GOOGLE",
"types" : [ "point_of_interest", "establishment" ],
"user_ratings_total" : 1,
"vicinity" : "Rarotonga"
},
{
"geometry" : {
"location" : {
"lat" : -21.2031499,
"lng" : -159.7862431
},
"viewport" : {
"northeast" : {
"lat" : -21.20180492010728,
"lng" : -159.7848997701073
},
"southwest" : {
"lat" : -21.20450457989272,
"lng" : -159.7875994298927
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "6c6524b3437e98c139998b5ec06ea81fd3ff2f5f",
"name" : "Black Watch Charters",
"place_id" : "ChIJP8sjaZbRV3ERaB06jfdehkY",
"plus_code" : {
"compound_code" : "Q6W7+PG Avarua District, Cook Islands",
"global_code" : "53C2Q6W7+PG"
},
"rating" : 0,
"reference" : "ChIJP8sjaZbRV3ERaB06jfdehkY",
"scope" : "GOOGLE",
"types" : [ "point_of_interest", "establishment" ],
"user_ratings_total" : 0,
"vicinity" : "Avarua District"
},
{
"geometry" : {
"location" : {
"lat" : -21.1994895,
"lng" : -159.8003902
},
"viewport" : {
"northeast" : {
"lat" : -21.19841532010728,
"lng" : -159.7989554201073
},
"southwest" : {
"lat" : -21.20111497989272,
"lng" : -159.8016550798928
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "5f02f471fe2868a51943041aa684874f8269ef7b",
"name" : "Raro Safari Tours & Concierge Desk",
"photos" : [
{
"height" : 3024,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/100947574557964297982\"\u003eJAY PILISI\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAA34pKKofPm9XF97_CcfSLVGq3y2AHn-linLaeEc1RfHRjpbJThl5EQuxKKmamNZ1i4cvqSu1-65He6nLolErQJLXEFDMPis4-5dKmK2TXS2-jyEsnrkcKKPiYqZD3B3jcEhC_GBl65rela41ctpewfxc3GhSt4oGQNCPui4k4j6vFU4o3hQWDDw",
"width" : 4032
}
],
"place_id" : "ChIJgRilfy3RV3ERpi1MKCgisSw",
"plus_code" : {
"compound_code" : "R52X+6R Avarua District, Cook Islands",
"global_code" : "53C2R52X+6R"
},
"rating" : 4.9,
"reference" : "ChIJgRilfy3RV3ERpi1MKCgisSw",
"scope" : "GOOGLE",
"types" : [
"tourist_attraction",
"travel_agency",
"point_of_interest",
"establishment"
],
"user_ratings_total" : 10,
"vicinity" : "Avarua District"
},
{
"geometry" : {
"location" : {
"lat" : -21.249997,
"lng" : -159.822227
},
"viewport" : {
"northeast" : {
"lat" : -21.24868352010728,
"lng" : -159.8209628201073
},
"southwest" : {
"lat" : -21.25138317989272,
"lng" : -159.8236624798928
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "affb3957b65c2ca105d0c5e63e547e22b6d73493",
"name" : "Adventure Cook Islands Ltd",
"opening_hours" : {
"open_now" : false
},
"photos" : [
{
"height" : 1063,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/111619238938552241021\"\u003eAdventure Cook Islands Ltd\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAQ4B12jlUrWlqwK1gWdfEEoGndrBWhviA8DTSI-Q-UoGmyR_7b7mkbtI361dC9dAZh3-Z0YlOYTdvVze9Vuw9qjFNecFMcPGO30ISi6DXCPezDEM_eTZj_mPbCDdLh8cyEhBlTzcXyYr7Atj69fRyPkVhGhQI_eSnR2CEQfCZNOXfM9UOC7uytA",
"width" : 1417
}
],
"place_id" : "ChIJOw686NzQV3ERYaRq_jbcJjw",
"plus_code" : {
"compound_code" : "Q52H+24 Arorangi District, Cook Islands",
"global_code" : "53C2Q52H+24"
},
"rating" : 4.9,
"reference" : "ChIJOw686NzQV3ERYaRq_jbcJjw",
"scope" : "GOOGLE",
"types" : [ "travel_agency", "point_of_interest", "establishment" ],
"user_ratings_total" : 21,
"vicinity" : "Kavera Beach, Arorangi Rarotonga"
},
{
"geometry" : {
"location" : {
"lat" : -21.220265,
"lng" : -159.828848
},
"viewport" : {
"northeast" : {
"lat" : -21.21891637010728,
"lng" : -159.8274922201073
},
"southwest" : {
"lat" : -21.22161602989272,
"lng" : -159.8301918798927
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "aca36479a072b313810c37ac835e50440bf3b81f",
"name" : "Dive Rarotonga",
"opening_hours" : {
"open_now" : false
},
"photos" : [
{
"height" : 337,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/102784390999532361399\"\u003eDive Rarotonga\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAW5A88HqZDDXA6her_GXw7zoxj2wB_U1O-tUubEBFNCteiAoPscB0o5-N5KvN-oY9TIaMnTD1-UhU1wNiX7-nSVMiUTIUcZIzEZFsDgJrO-xPL0hbm5jE887kq3V1VYVIEhCpMlOYcEqSDWLEDAPcnodCGhSBnJ1dO8GpFHZEnTMP6l9t2zpZpA",
"width" : 600
}
],
"place_id" : "ChIJkSU-1V3QV3ER3yczeMV8I_k",
"plus_code" : {
"compound_code" : "Q5HC+VF Arorangi District, Cook Islands",
"global_code" : "53C2Q5HC+VF"
},
"rating" : 4.9,
"reference" : "ChIJkSU-1V3QV3ER3yczeMV8I_k",
"scope" : "GOOGLE",
"types" : [ "travel_agency", "point_of_interest", "store", "establishment" ],
"user_ratings_total" : 33,
"vicinity" : "Yellow A-Frame, Main Road, Arorangi District"
},
{
"geometry" : {
"location" : {
"lat" : -21.252595,
"lng" : -159.730144
},
"viewport" : {
"northeast" : {
"lat" : -21.25122567010727,
"lng" : -159.7289091701073
},
"southwest" : {
"lat" : -21.25392532989272,
"lng" : -159.7316088298927
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "f0b212e097fc057cb51138594070cfe5c014d436",
"name" : "Pacific Divers",
"opening_hours" : {
"open_now" : false
},
"place_id" : "ChIJRUYyzojTV3ER9iL5iSVfHNo",
"plus_code" : {
"compound_code" : "P7W9+XW Ngatangiia District, Cook Islands",
"global_code" : "53C2P7W9+XW"
},
"rating" : 0,
"reference" : "ChIJRUYyzojTV3ER9iL5iSVfHNo",
"scope" : "GOOGLE",
"types" : [ "travel_agency", "school", "point_of_interest", "establishment" ],
"user_ratings_total" : 0,
"vicinity" : "Ara Tapu, Muri"
},
{
"geometry" : {
"location" : {
"lat" : -21.2012422,
"lng" : -159.8060292
},
"viewport" : {
"northeast" : {
"lat" : -21.19968582010728,
"lng" : -159.8046350701073
},
"southwest" : {
"lat" : -21.20238547989272,
"lng" : -159.8073347298927
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "e53fbdf110553cb3a56e69dedfc348e1da4e0172",
"name" : "Turama Pacific Travel Group",
"photos" : [
{
"height" : 525,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/104663734301544398423\"\u003eA Google User\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAvgs-ezM5FNldJ1bfCf_sV0Ql58Nj54UKuirPef1T0FNqc6U2YLdpREuexg20VBWNwRdet--vuGenVsazreVEio-ezp4VEzYbrMv2BVbILKGswlL83NN8hT0BPEK3gTOaEhADvZmluOWXh0kRYgtcRE3oGhQ95v3wdXzFgfh06tOico2RmMJWiA",
"width" : 700
}
],
"place_id" : "ChIJuUvKeLbRV3EROJNkUZhNG5g",
"plus_code" : {
"compound_code" : "Q5XV+GH Avarua District, Cook Islands",
"global_code" : "53C2Q5XV+GH"
},
"rating" : 5,
"reference" : "ChIJuUvKeLbRV3EROJNkUZhNG5g",
"scope" : "GOOGLE",
"types" : [ "travel_agency", "point_of_interest", "establishment" ],
"user_ratings_total" : 1,
"vicinity" : "Avarua District"
}
],
"status" : "OK"
}
Hope this helps!
i'm developing an app that use google API to obtain a transport solution to reach a location at a desired time.
My code that call google API work perfectly with "driving" and "walking" travel mode, but with "transit" and "bicycling" the response is always marked with the status "ZERO_RESULTS" and no routes is calculated.
This, by the google documentation, means that transit and bicycling are not available in the country where the solution must be calculated.
I tried with several country and I always had the same result, I tried also with the Google example (for transit) in the overview and it doesn't work.
The parameters that I pass with the HTTPS request are: origin, destination, travel mode, arrival_time.
The first thing that I tried is to change arrival_time, in case the value is referred to the past or to a too distant future, but it doesn't work.
In case I don't pass "arrival_time" the response is perfect, but I don't understand because in the Google Documentation is clear that arrival_time is a possible argument of the https request also with the transit travel mode. Without this argument the request is useless for my goal.
The curious thing is that if i pass "transit" (with arrival or departure time) the response is this:
{
"available_travel_modes" : [ "DRIVING", "WALKING" ],
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJu46S-ZZhLxMROG5lkwZ3D7k",
"types" : [ "locality", "political" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJ53USP0nBhkcRjQ50xhPN_zw",
"types" : [ "locality", "political" ]
}
],
"routes" : [],
"status" : "ZERO_RESULTS"
}
And if I pass "bicycling" (with all the other parameters unchanged):
{
"available_travel_modes" : [ "DRIVING", "WALKING", "TRANSIT" ],
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJu46S-ZZhLxMROG5lkwZ3D7k",
"types" : [ "locality", "political" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJ53USP0nBhkcRjQ50xhPN_zw",
"types" : [ "locality", "political" ]
}
],
"routes" : [],
"status" : "ZERO_RESULTS"
}
So in the second case the API said that TRANSIT is available and this doesn't make sense at all!
The format of the location that I use is geographical coordinates to avoid cases of ambiguity.
Hope that I give enough information to make you able to help me.
EDIT: sorry, i was thinking that my post was clear enough.
I use Google Directions API: https://developers.google.com/maps/documentation/directions/
My problem is with "transit" and "bicycling" as travel mode and is not a code problem, but the problem appears at the level of https response, even with the google example for "transit" that can be found on the overview i obtain a "ZERO_RESULTS" response.
This is the URL of the example:
https://maps.googleapis.com/maps/api/directions/json?origin=75+9th+Ave+New+York,+NY&destination=MetLife+Stadium+1+MetLife+Stadium+Dr+East+Rutherford,+NJ+07073&mode=transit&arrival_time=1391374800&key=YOUR_API_KEY
And here is the two URL that get me the two response that I copied above:
with transit:
https://maps.googleapis.com/maps/api/directions/json?origin=Rome&destination=Milan&mode=transit&arrival_time=1513162800000&key=++API_KEY++
and with bicycling:
https://maps.googleapis.com/maps/api/directions/json?origin=Rome&destination=Milan&mode=transit&arrival_time=1513162800000&key=++API_KEY++
in the code I use for origin and destination geographical coordinates as here:
https://maps.googleapis.com/maps/api/directions/json?origin=41.9027835,12.496365500000024&destination=45.4642035,9.189981999999986&mode=transit&arrival_time=1513162800000&key=++API_KEY++
the only difference is that google do not recognize geocoded waypoints:
{
"available_travel_modes" : [ "DRIVING", "WALKING" ],
"geocoded_waypoints" : [ {}, {} ],
"routes" : [],
"status" : "ZERO_RESULTS"
}
If I use "driving" as travel mode this worked:
https://maps.googleapis.com/maps/api/directions/json?origin=41.9027835,12.496365500000024&destination=45.4642035,9.189981999999986&mode=driving&arrival_time=1513162800000&key=++API_KEY++
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "EjJQaWF6emEgZGVsbGEgUmVwdWJibGljYSwgMTAsIDAwMTg1IFJvbWEgUk0sIEl0YWxpYQ",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJC5u9LazGhkcRXAZQFNDTpKc",
"types" : [ "street_address" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 45.4731019,
"lng" : 12.6177051
},
"southwest" : {
"lat" : 41.9028523,
"lng" : 9.1839517
}
},
"copyrights" : "Dati mappa ©2017 Google",
"legs" : [
{
"distance" : {
"text" : "573 km",
"value" : 572600
},
"duration" : {
"text" : "5 ore 51 min",
"value" : 21069
},
"end_address" : "Via Silvio Pellico, 2, 20121 Milano MI, Italia",
"end_location" : {
"lat" : 45.46495119999999,
"lng" : 9.1892874
},
"start_address" : "Piazza della Repubblica, 10, 00185 Roma RM, Italia",
"start_location" : {
"lat" : 41.9028523,
"lng" : 12.4964704
},
"steps" : [
{
"distance" : {
"text" : "93 m",
"value" : 93
},
"duration" : {
"text" : "1 min",
"value" : 19
},
"end_location" : {
"lat" : 41.9035781,
"lng" : 12.4959908
},
"html_instructions" : "Procedi in direzione \u003cb\u003enord\u003c/b\u003e da \u003cb\u003ePiazza della Repubblica\u003c/b\u003e verso \u003cb\u003eVia Giuseppe Romita\u003c/b\u003e",
"polyline" : {
"points" : "ycw~F}ugkAU?I#E#E#a#RG#EDED_#d#OP"
},
"start_location" : {
"lat" : 41.9028523,
"lng" : 12.4964704
},
"travel_mode" : "DRIVING"
},
// cut
{
"distance" : {
"text" : "52 m",
"value" : 52
},
"duration" : {
"text" : "1 min",
"value" : 14
},
"end_location" : {
"lat" : 45.4665738,
"lng" : 9.1889772
},
"html_instructions" : "Continua su \u003cb\u003eVia Santa Margherita\u003c/b\u003e",
"polyline" : {
"points" : "ogotGoxaw#`#`#j#h#"
},
"start_location" : {
"lat" : 45.4669622,
"lng" : 9.189359399999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 km",
"value" : 192
},
"duration" : {
"text" : "1 min",
"value" : 87
},
"end_location" : {
"lat" : 45.46495119999999,
"lng" : 9.1892874
},
"html_instructions" : "Svolta a \u003cb\u003esinistra\u003c/b\u003e e prendi \u003cb\u003eVia Silvio Pellico\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "aeotGcvaw#Xw#DCBAxC#~A?d#A"
},
"start_location" : {
"lat" : 45.4665738,
"lng" : 9.1889772
},
"travel_mode" : "DRIVING"
}
],
"traffic_speed_entry" : [],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "//collapsed//"
},
"summary" : "A1/E35 e A1",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}
and if I use "transit" without an arrival time it works:
https://maps.googleapis.com/maps/api/directions/json?origin=41.9027835,12.496365500000024&destination=45.4642035,9.
189981999999986&mode=transit&key=++API_KEY++
and:
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "EjJQaWF6emEgZGVsbGEgUmVwdWJibGljYSwgMTAsIDAwMTg1IFJvbWEgUk0sIEl0YWxpYQ",
"types" : [ "street_address" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJRYxePKzGhkcRsgPwamn2Pfo",
"types" : [ "street_address" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 45.4969308,
"lng" : 12.5528041
},
"southwest" : {
"lat" : 41.892252,
"lng" : 9.188611
}
},
"copyrights" : "Dati mappa ©2017 Google",
"legs" : [
{
"arrival_time" : {
"text" : "13:55",
"time_zone" : "Europe/Rome",
"value" : 1513169733
},
"departure_time" : {
"text" : "10:10",
"time_zone" : "Europe/Rome",
"value" : 1513156231
},
"distance" : {
"text" : "571 km",
"value" : 571467
},
"duration" : {
"text" : "3 ore 45 min",
"value" : 13502
},
"end_address" : "Piazza del Duomo, 1, 20121 Milano MI, Italia",
"end_location" : {
"lat" : 45.4639037,
"lng" : 9.188611
},
"start_address" : "Piazza della Repubblica, 10, 00185 Roma RM, Italia",
"start_location" : {
"lat" : 41.9028429,
"lng" : 12.4964793
},
"steps" : [
{
"distance" : {
"text" : "0,1 km",
"value" : 102
},
"duration" : {
"text" : "1 min",
"value" : 87
},
"end_location" : {
"lat" : 41.902193,
"lng" : 12.4958041
},
"html_instructions" : "Cammina fino a Repubblica",
"polyline" : {
"points" : "wcw~F_vgkA#CBADABA#A#?B?D?B?B#B?B#BBB##BBBDH#D#H##?D?BDRBL?#DXBLBJDHBFVM"
},
"start_location" : {
"lat" : 41.9028429,
"lng" : 12.4964793
},
"steps" : [
{
"distance" : {
"text" : "54 m",
"value" : 54
},
"duration" : {
"text" : "1 min",
"value" : 49
},
"end_location" : {
"lat" : 41.9024775,
"lng" : 12.4962611
},
"html_instructions" : "Procedi in direzione \u003cb\u003esudest\u003c/b\u003e verso \u003cb\u003ePiazza della Repubblica\u003c/b\u003e",
"polyline" : {
"points" : "wcw~F_vgkA#CBADABA#A#?B?D?B?B#B?B#BBB##BBBDH#D#H##?D?B"
},
"start_location" : {
"lat" : 41.9028429,
"lng" : 12.4964793
},
"travel_mode" : "WALKING"
},
{
"distance" : {
"text" : "48 m",
"value" : 48
},
"duration" : {
"text" : "1 min",
"value" : 38
},
"end_location" : {
"lat" : 41.902193,
"lng" : 12.4958041
},
"html_instructions" : "Esci dalla rotonda e prendi \u003cb\u003ePiazza della Repubblica\u003c/b\u003e",
"polyline" : {
"points" : "oaw~FstgkADRBL?#DXBLBJDHBFVM"
},
"start_location" : {
"lat" : 41.9024775,
"lng" : 12.4962611
},
"travel_mode" : "WALKING"
}
],
"travel_mode" : "WALKING"
},
{
"distance" : {
"text" : "0,4 km",
"value" : 437
},
"duration" : {
"text" : "1 min",
"value" : 46
},
"end_location" : {
"lat" : 41.9011732,
"lng" : 12.4996019
},
"html_instructions" : "Metropolitana verso Anagnina",
"polyline" : {
"points" : "u_w~FwqgkAeBIBoA#I|ByM~CmELR"
},
"start_location" : {
"lat" : 41.902193,
"lng" : 12.4958041
},
"transit_details" : {
"arrival_stop" : {
"location" : {
"lat" : 41.9011732,
"lng" : 12.4996019
},
"name" : "Termini"
},
"arrival_time" : {
"text" : "10:12",
"time_zone" : "Europe/Rome",
"value" : 1513156353
},
"departure_stop" : {
"location" : {
"lat" : 41.902193,
"lng" : 12.4958041
},
"name" : "Repubblica"
},
"departure_time" : {
"text" : "10:11",
"time_zone" : "Europe/Rome",
"value" : 1513156307
},
"headsign" : "Anagnina",
"line" : {
"agencies" : [
{
"name" : "Atac",
"phone" : "011 39 06 57003",
"url" : "http://www.atac.roma.it/"
}
],
"color" : "#e27439",
"name" : "Metro A",
"short_name" : "MEA",
"url" : "http://muovi.roma.it/percorso/js?query=MEA&cl=1",
"vehicle" : {
"icon" : "//maps.gstatic.com/mapfiles/transit/iw2/6/subway2.png",
"local_icon" : "//maps.gstatic.com/mapfiles/transit/iw2/6/it-metro.png",
"name" : "Metropolitana",
"type" : "SUBWAY"
}
},
"num_stops" : 1
},
"travel_mode" : "TRANSIT"
},
{
"distance" : {
"text" : "2,6 km",
"value" : 2641
},
"duration" : {
"text" : "6 min",
"value" : 330
},
"end_location" : {
"lat" : 45.4639037,
"lng" : 9.188611
},
"html_instructions" : "Metropolitana verso San Donato",
"polyline" : {
"points" : "//collapsed//"
},
"start_location" : {
"lat" : 45.4844397,
"lng" : 9.202612799999999
},
"transit_details" : {
"arrival_stop" : {
"location" : {
"lat" : 45.4639037,
"lng" : 9.188611
},
"name" : "Duomo"
},
"arrival_time" : {
"text" : "13:55",
"time_zone" : "Europe/Rome",
"value" : 1513169730
},
"departure_stop" : {
"location" : {
"lat" : 45.4844397,
"lng" : 9.202612799999999
},
"name" : "Centrale FS"
},
"departure_time" : {
"text" : "13:50",
"time_zone" : "Europe/Rome",
"value" : 1513169400
},
"headsign" : "San Donato",
"line" : {
"agencies" : [
{
"name" : "COMUNE DI MILANO",
"phone" : "011 39 02 0202",
"url" : "http://www.muoversi.milano.it/"
}
],
"color" : "#ffea00",
"name" : "M3 - Linea Gialla",
"short_name" : "3",
"vehicle" : {
"icon" : "//maps.gstatic.com/mapfiles/transit/iw2/6/subway2.png",
"local_icon" : "//maps.gstatic.com/mapfiles/transit/iw2/6/it-metro.png",
"name" : "Metropolitana",
"type" : "SUBWAY"
}
},
"num_stops" : 4
},
"travel_mode" : "TRANSIT"
}
],
"traffic_speed_entry" : [],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "//collapsed//"
},
"summary" : "",
"warnings" : [
"Le indicazioni per tragitti a piedi sono in versione beta. Presta attenzione – questo percorso potrebbe non disporre di marciapiede o aree pedonali."
],
"waypoint_order" : []
}
],
"status" : "OK"
}
The issue in your request is the value that you pass as an arrival_time parameter. Please note that this value must be in seconds:
arrival_time — Specifies the desired time of arrival for transit directions, in seconds since midnight, January 1, 1970 UTC. You can specify either departure_time or arrival_time, but not both. Note that arrival_time must be specified as an integer.
https://developers.google.com/maps/documentation/directions/intro#DirectionsRequests
You are passing milliseconds 1513162800000 that corresponds to 03/22/49920 # 8:00am (UTC), the correct value is 1513162800 that corresponds to 12/13/2017 # 11:00am (UTC).
The request should be:
https://maps.googleapis.com/maps/api/directions/json?origin=41.9027835%2C12.496365500000024&destination=45.4642035%2C9.189981999999986&mode=transit&arrival_time=1513162800&key=YOUR_API_KEY
The same request in Directions calculator:
https://directionsdebug.firebaseapp.com/?origin=41.9027835%2C12.496365500000024&destination=45.4642035%2C9.189981999999986&mode=transit&arrival_time=1513162800
I hope this helps!
In case it helps someone else, I also found that setting a departure_time too far in the future (more than a year in my case) led to a "ZERO_RESULTS" response. Making it closer to the present fixed this.
I'm trying to get routes of origin -> waypoint -> destination
Everything works well except of one specific request:
Origin (Point A) : PH Benidor, Calle Gaspar O. Hernández, Panamá
Waypoint (Point B): BAC Credomatic | Sucursal Plaza New York, Calle 50, Panamá
Destination (Point A): PH Benidor, Calle Gaspar O. Hernández, Panamá
So if I make request from A -> B - everything works fine, making B -> A works also. A -> A works as well. As soon as I do a waypoint for that specific (B) address, google API returns ZERO_RESULT.
Check URL: https://maps.googleapis.com/maps/api/directions/json?key=<API_KEY>&mode=driving&origin=PH+Benidor%2C+Calle+Gaspar+O.+Hern%C3%A1ndez%2C+Panam%C3%A1&destination=PH+Benidor%2C+Calle+Gaspar+O.+Hern%C3%A1ndez%2C+Panam%C3%A1&alternatives=true&units=metric&waypoints=BAC+Credomatic+|+Sucursal+Plaza+New+York%2C+Calle+50%2C+Panam%C3%A1
UPDATE
Addresses are taken from Google Autocomplete API field, so I assume they are correctly formatted. Route from A -> B works well with same addresses
https://maps.googleapis.com/maps/api/directions/json?key=API_KEY&alternatives=true&units=metric&mode=driving&origin=PH+Benidor%2C+Calle+Gaspar+O.+Hern%C3%A1ndez%2C+Panam%C3%A1&destination=BAC+Credomatic+|+Sucursal+Plaza+New+York%2C+Calle+50%2C+Panam%C3%A1
Response
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJxX3EIvqorI8RRhwI3jYajZc",
"types" : [ "premise" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJMR2dd-OorI8ROKhRZctCf0k",
"types" : [
"bus_station",
"establishment",
"point_of_interest",
"transit_station"
]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 8.9896817,
"lng" : -79.52026149999999
},
"southwest" : {
"lat" : 8.979656199999999,
"lng" : -79.52709229999999
}
},
"copyrights" : "Картографические данные © 2017 Google",
"legs" : [
{
"distance" : {
"text" : "2,1 км",
"value" : 2052
},
"duration" : {
"text" : "8 мин.",
"value" : 480
},
"end_address" : "Calle 50, Panamá, Панама",
"end_location" : {
"lat" : 8.982186499999999,
"lng" : -79.52026149999999
},
"start_address" : "PH Benidor, Calle Gaspar O. Hernández, Panamá, Панама",
"start_location" : {
"lat" : 8.9896817,
"lng" : -79.5251863
},
"steps" : [
{
"distance" : {
"text" : "0,1 км",
"value" : 111
},
"duration" : {
"text" : "1 мин.",
"value" : 50
},
"end_location" : {
"lat" : 8.9887005,
"lng" : -79.52522759999999
},
"html_instructions" : "Направляйтесь на \u003cb\u003eюг\u003c/b\u003e по \u003cb\u003eCalle Gaspar O. Hernández\u003c/b\u003e в сторону \u003cb\u003eVía Argentina\u003c/b\u003e",
"polyline" : {
"points" : "oxzu#lgkdNbDR^K"
},
"start_location" : {
"lat" : 8.9896817,
"lng" : -79.5251863
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 км",
"value" : 241
},
"duration" : {
"text" : "2 мин.",
"value" : 99
},
"end_location" : {
"lat" : 8.987735199999999,
"lng" : -79.52327099999999
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eVía Argentina\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "krzu#tgkdNDKr#wBLc#N[b#kAr#}AHQBE#A"
},
"start_location" : {
"lat" : 8.9887005,
"lng" : -79.52522759999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,7 км",
"value" : 737
},
"duration" : {
"text" : "2 мин.",
"value" : 128
},
"end_location" : {
"lat" : 8.982404600000001,
"lng" : -79.52709229999999
},
"html_instructions" : "Поверните \u003cb\u003eнаправо\u003c/b\u003e на \u003cb\u003eVía España\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "klzu#l{jdNf#Hl#Nb#Ld#Lj#Xn#`#z#t#Zd#JRHJT\\PVPPNNVNj#^\\P`FzCh#VhAp#j#p###pCxA"
},
"start_location" : {
"lat" : 8.987735199999999,
"lng" : -79.52327099999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,4 км",
"value" : 424
},
"duration" : {
"text" : "2 мин.",
"value" : 105
},
"end_location" : {
"lat" : 8.979656199999999,
"lng" : -79.5244422
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eCalle Aquilino de la Guardia\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "_kyu#hskdNBE#ADE`CcDp#w#d#i#j#e#xBeBd#[~#s#p#a#"
},
"start_location" : {
"lat" : 8.982404600000001,
"lng" : -79.52709229999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,5 км",
"value" : 539
},
"duration" : {
"text" : "2 мин.",
"value" : 98
},
"end_location" : {
"lat" : 8.982186499999999,
"lng" : -79.52026149999999
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eCalle 50\u003c/b\u003e/\u003cb\u003eCalle Nicanor de Obarrio\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eПункт назначения будет справа\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "{yxu#vbkdNkAcCmAgCOWm#kACECCg#gAm#aA}CcGe#{#"
},
"start_location" : {
"lat" : 8.979656199999999,
"lng" : -79.5244422
},
"travel_mode" : "DRIVING"
}
],
"traffic_speed_entry" : [],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "oxzu#lgkdNbDR^KDK`A{Cr#gB|#oBDGtAXhAZj#Xn#`#z#t#Zd#T^f#t#`#`#bAn#~FlDrBhAl#r#pCxABEFGrD{EpAoA~CaC~#s#p#a#yCkGeAmBuAiCcE_I"
},
"summary" : "Vía España и Calle 50/Calle Nicanor de Obarrio",
"warnings" : [],
"waypoint_order" : []
},
{
"bounds" : {
"northeast" : {
"lat" : 8.9896817,
"lng" : -79.52026149999999
},
"southwest" : {
"lat" : 8.9806346,
"lng" : -79.52528719999999
}
},
"copyrights" : "Картографические данные © 2017 Google",
"legs" : [
{
"distance" : {
"text" : "2,1 км",
"value" : 2149
},
"duration" : {
"text" : "10 мин.",
"value" : 588
},
"end_address" : "Calle 50, Panamá, Панама",
"end_location" : {
"lat" : 8.982186499999999,
"lng" : -79.52026149999999
},
"start_address" : "PH Benidor, Calle Gaspar O. Hernández, Panamá, Панама",
"start_location" : {
"lat" : 8.9896817,
"lng" : -79.5251863
},
"steps" : [
{
"distance" : {
"text" : "0,1 км",
"value" : 111
},
"duration" : {
"text" : "1 мин.",
"value" : 50
},
"end_location" : {
"lat" : 8.9887005,
"lng" : -79.52522759999999
},
"html_instructions" : "Направляйтесь на \u003cb\u003eюг\u003c/b\u003e по \u003cb\u003eCalle Gaspar O. Hernández\u003c/b\u003e в сторону \u003cb\u003eVía Argentina\u003c/b\u003e",
"polyline" : {
"points" : "oxzu#lgkdNbDR^K"
},
"start_location" : {
"lat" : 8.9896817,
"lng" : -79.5251863
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 км",
"value" : 241
},
"duration" : {
"text" : "2 мин.",
"value" : 99
},
"end_location" : {
"lat" : 8.987735199999999,
"lng" : -79.52327099999999
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eVía Argentina\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "krzu#tgkdNDKr#wBLc#N[b#kAr#}AHQBE#A"
},
"start_location" : {
"lat" : 8.9887005,
"lng" : -79.52522759999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 км",
"value" : 238
},
"duration" : {
"text" : "1 мин.",
"value" : 43
},
"end_location" : {
"lat" : 8.985976599999999,
"lng" : -79.52439769999999
},
"html_instructions" : "Поверните \u003cb\u003eнаправо\u003c/b\u003e на \u003cb\u003eVía España\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "klzu#l{jdNf#Hl#Nb#Ld#Lj#Xn#`#z#t#Zd#JR"
},
"start_location" : {
"lat" : 8.987735199999999,
"lng" : -79.52327099999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 км",
"value" : 231
},
"duration" : {
"text" : "1 мин.",
"value" : 59
},
"end_location" : {
"lat" : 8.9846278,
"lng" : -79.5227939
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eCalle 52 Este\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "kazu#nbkdNFGR]pF{G"
},
"start_location" : {
"lat" : 8.985976599999999,
"lng" : -79.52439769999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,1 км",
"value" : 149
},
"duration" : {
"text" : "1 мин.",
"value" : 62
},
"end_location" : {
"lat" : 8.9853383,
"lng" : -79.52164499999999
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eAv. Samuel Lewis\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "}xyu#lxjdNWe#MSMQyAyC"
},
"start_location" : {
"lat" : 8.9846278,
"lng" : -79.5227939
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 км",
"value" : 183
},
"duration" : {
"text" : "1 мин.",
"value" : 41
},
"end_location" : {
"lat" : 8.9839468,
"lng" : -79.52075069999999
},
"html_instructions" : "Поверните \u003cb\u003eнаправо\u003c/b\u003e на \u003cb\u003eCalle 54 Este\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "k}yu#fqjdNpGmDBC"
},
"start_location" : {
"lat" : 8.9853383,
"lng" : -79.52164499999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,3 км",
"value" : 332
},
"duration" : {
"text" : "1 мин.",
"value" : 74
},
"end_location" : {
"lat" : 8.982836499999999,
"lng" : -79.5233909
},
"html_instructions" : "Поверните \u003cb\u003eнаправо\u003c/b\u003e на перекрестке 1 на \u003cb\u003eAv. Ricardo Arango\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "utyu#tkjdNzAlC##rCvESfD"
},
"start_location" : {
"lat" : 8.9839468,
"lng" : -79.52075069999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "88 м",
"value" : 88
},
"duration" : {
"text" : "1 мин.",
"value" : 19
},
"end_location" : {
"lat" : 8.982181299999999,
"lng" : -79.52383399999999
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eAvenida Ricardo Arango\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "wmyu#d|jdNbCvA"
},
"start_location" : {
"lat" : 8.982836499999999,
"lng" : -79.5233909
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 км",
"value" : 197
},
"duration" : {
"text" : "1 мин.",
"value" : 58
},
"end_location" : {
"lat" : 8.9806346,
"lng" : -79.523155
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eCalle Beatriz M. de Cabal\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "siyu#|~jdN~BoB~AS`AAJ?F?"
},
"start_location" : {
"lat" : 8.982181299999999,
"lng" : -79.52383399999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "61 м",
"value" : 61
},
"duration" : {
"text" : "1 мин.",
"value" : 26
},
"end_location" : {
"lat" : 8.9809009,
"lng" : -79.52267329999999
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e в сторону \u003cb\u003eCalle 50\u003c/b\u003e/\u003cb\u003eCalle Nicanor de Obarrio\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "}_yu#vzjdNMYg#gA"
},
"start_location" : {
"lat" : 8.9806346,
"lng" : -79.523155
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "19 м",
"value" : 19
},
"duration" : {
"text" : "1 мин.",
"value" : 7
},
"end_location" : {
"lat" : 8.9807585,
"lng" : -79.52257179999999
},
"html_instructions" : "Поверните \u003cb\u003eнаправо\u003c/b\u003e в сторону \u003cb\u003eCalle 50\u003c/b\u003e/\u003cb\u003eCalle Nicanor de Obarrio\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "sayu#twjdNZQ?A"
},
"start_location" : {
"lat" : 8.9809009,
"lng" : -79.52267329999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,3 км",
"value" : 299
},
"duration" : {
"text" : "1 мин.",
"value" : 50
},
"end_location" : {
"lat" : 8.982186499999999,
"lng" : -79.52026149999999
},
"html_instructions" : "Поверните \u003cb\u003eналево\u003c/b\u003e на \u003cb\u003eCalle 50\u003c/b\u003e/\u003cb\u003eCalle Nicanor de Obarrio\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eПункт назначения будет справа\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "w`yu#`wjdNCCg#gAm#aA}CcGe#{#"
},
"start_location" : {
"lat" : 8.9807585,
"lng" : -79.52257179999999
},
"travel_mode" : "DRIVING"
}
],
"traffic_speed_entry" : [],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "oxzu#lgkdNbDR^KDK`A{Cr#gB|#oBDGtAXhAZj#Xn#`#z#t#Zd#JRFGdGyHe#y#MQyAyCtGqD|AnCrCvESfDbCvA~BoB~AS`AAR?u#aBZSk#kAkEeIe#{#"
},
"summary" : "Av. Ricardo Arango",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}
So I assume that something wrong with the address if it is in waypoints parameter.
I checked the Directions API request with origin, destination and waypoints from your question
https://maps.googleapis.com/maps/api/directions/json?origin=PH%20Benidor%2C%20Calle%20Gaspar%20O.%20Hern%C3%A1ndez%2C%20Panam%C3%A1&destination=PH%20Benidor%2C%20Calle%20Gaspar%20O.%20Hern%C3%A1ndez%2C%20Panam%C3%A1&mode=driving&waypoints=BAC%20Credomatic%7CSucursal%20Plaza%20New%20York%2C%20Calle%2050%2C%20Panam%C3%A1&key=MY_API_KEY
The response contains following geocoded waypoints:
"geocoded_waypoints":[
{
"geocoder_status":"OK",
"place_id":"ChIJxX3EIvqorI8RRhwI3jYajZc",
"types":[
"premise"
]
},
{
"geocoder_status":"OK",
"place_id":"ChIJZ1RH5IDoaY8RcqGCRNAAPQw",
"types":[
"establishment","finance","point_of_interest"
]
},
{
"geocoder_status":"OK",
"place_id":"ChIJf1seg-OorI8R_66YzaG7hko",
"types":[
"bank","establishment","finance","food","point_of_interest","restaurant"
]
},
{
"geocoder_status":"OK",
"place_id":"ChIJxX3EIvqorI8RRhwI3jYajZc",
"types":[
"premise"
]
}]
Let's have a look at waypoint with place ID ChIJZ1RH5IDoaY8RcqGCRNAAPQw. It corresponds to the 'BAC Credomatic' in your request. If you check the place ID with geocoder tool, you will see that the 'BAC Credomatic' is resolved to business location in Honduras that located in island and cannot be reached by car.
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#place_id%3DChIJZ1RH5IDoaY8RcqGCRNAAPQw
This is a reason for ZERO_RESULTS. You must be more precise when specify addresses of waypoints. Have a look at the following document that explains how to format address strings properly:
https://developers.google.com/maps/faq#geocoder_queryformat
I hope this helps!
I'm using SwiftyJSON.
I have a json string like this:
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJkcemZ9r9jT8RCoy7cipVk3Q",
"types" : [ "route" ]
},
{
"geocoder_status" : "OK",
"place_id" : "ChIJzYyVGtcFjj8RMoV0IaoNhzA",
"types" : [ "route" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 35.7884236,
"lng" : 51.43490389999999
},
"southwest" : {
"lat" : 35.7056256,
"lng" : 51.3073962
}
},
"copyrights" : "Map data ©2017 Google",
"legs" : [
{
"distance" : {
"text" : "20.9 km",
"value" : 20893
},
"duration" : {
"text" : "32 mins",
"value" : 1936
},
"end_address" : "Tehran Province, Tehran, Hossein, Iran",
"end_location" : {
"lat" : 35.7883586,
"lng" : 51.43490389999999
},
"start_address" : "Tehran Province, Tehran, Kooy-e-Bimeh, Rostam, Iran",
"start_location" : {
"lat" : 35.7056307,
"lng" : 51.3167437
},
"steps" : [
{
"distance" : {
"text" : "59 m",
"value" : 59
},
"duration" : {
"text" : "1 min",
"value" : 21
},
"end_location" : {
"lat" : 35.70562779999999,
"lng" : 51.31739839999999
},
"html_instructions" : "Head \u003cb\u003eeast\u003c/b\u003e on \u003cb\u003eRostam\u003c/b\u003e toward \u003cb\u003e4th Bimeh St\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Burgerich (on the right)\u003c/div\u003e",
"polyline" : {
"points" : "ew|xEsxexH?W?w#?s#"
},
"start_location" : {
"lat" : 35.7056307,
"lng" : 51.3167437
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.1 km",
"value" : 135
},
"duration" : {
"text" : "1 min",
"value" : 30
},
"end_location" : {
"lat" : 35.7868183,
"lng" : 51.4303372
},
"html_instructions" : "Continue onto \u003cb\u003eSharifi Manesh St\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Embassy of Switzerland In Tehran (on the left)\u003c/div\u003e",
"polyline" : {
"points" : "cllyEyy{xHSIQSIIYWk#[_Ak#YQ"
},
"start_location" : {
"lat" : 35.7857769,
"lng" : 51.4295729
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.3 km",
"value" : 304
},
"duration" : {
"text" : "1 min",
"value" : 51
},
"end_location" : {
"lat" : 35.7852475,
"lng" : 51.4330904
},
"html_instructions" : "\u003cb\u003eSharifi Manesh St\u003c/b\u003e turns \u003cb\u003eright\u003c/b\u003e and becomes \u003cb\u003eElahiyeh St\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by باشگاه الهیه (on the left)\u003c/div\u003e",
"polyline" : {
"points" : "srlyEs~{xHpBwEdA}BxAqCf#}#"
},
"start_location" : {
"lat" : 35.7868183,
"lng" : 51.4303372
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.4 km",
"value" : 359
},
"duration" : {
"text" : "1 min",
"value" : 70
},
"end_location" : {
"lat" : 35.7884241,
"lng" : 51.4337388
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eKhazar St\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by MaryamHair (on the left)\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "yhlyEyo|xHwBYwCg#wA[}AQuAM}AC"
},
"start_location" : {
"lat" : 35.7852475,
"lng" : 51.4330904
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.1 km",
"value" : 105
},
"duration" : {
"text" : "1 min",
"value" : 39
},
"end_location" : {
"lat" : 35.7883586,
"lng" : 51.43490389999999
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at هنرستان مفتح onto \u003cb\u003eHossein\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "s|lyE{s|xH?AJeF"
},
"start_location" : {
"lat" : 35.7884241,
"lng" : 51.4337388
},
"travel_mode" : "DRIVING"
}
],
"traffic_speed_entry" : [],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "ew|xEsxexH?oA"
},
"summary" : "Hakim Expy",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}
what I want to get is routes->legs->distance->text.
my codes:
let json = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as! String
if let data = json.data(using: String.Encoding.utf8) {
let json = JSON(data: data)
print("--->\(json["routes"]["legs"]["distance"]["text"].string)")
}
print returns --->nil.
routes and legs are arrays, you have to get the first entry first:
let json = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as! String
if let data = json.data(using: String.Encoding.utf8) {
let json = JSON(data: data)
if let route = json["routes"].first {
if let leg = route["legs"].first {
print("--->\(leg["distance"]["text"].string)")
}
}
}
p.s. You may need to do some logic checking if you don't want the first entry in the arrays.
How to change google map JSON so that redundant stuff is not downloaded and speed up an app on low bandwidth networks. For example app doesn't support navigation hence steps are not required in JSON which is also downloaded and makes app slow on low bandwidth networks.
For Example:-
Google Map JSON between source and destination:-
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJbZ--gzESrjsRsmxa_tmvhlI",
"types" : [ "route" ]
},
{
"geocoder_status" : "OK",
"place_id" : "Elk4NjksIDEydGggTWFpbiBSb2FkLCBLb3JhbWFuZ2FsYSAzIEJsb2NrLCBLb3JhbWFuZ2FsYSwgQmVuZ2FsdXJ1LCBLYXJuYXRha2EgNTYwMDM0LCBJbmRpYQ",
"types" : [ "street_address" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 12.959155,
"lng" : 77.7091214
},
"southwest" : {
"lat" : 12.9206335,
"lng" : 77.6264824
}
},
"copyrights" : "Map data ©2015 Google",
"legs" : [
{
"distance" : {
"text" : "12.5 km",
"value" : 12510
},
"duration" : {
"text" : "29 mins",
"value" : 1750
},
"end_address" : "869, 12th Main Road, Koramangala 3 Block, Koramangala, Bengaluru, Karnataka 560034, India",
"end_location" : {
"lat" : 12.9280212,
"lng" : 77.6267905
},
"start_address" : "PFS Driveway, Lakshminarayana Pura, AECS Layout, Marathahalli, Bengaluru, Karnataka 560037, India",
"start_location" : {
"lat" : 12.959155,
"lng" : 77.70615509999999
},
"steps" : [
{
"distance" : {
"text" : "0.3 km",
"value" : 283
},
"duration" : {
"text" : "1 min",
"value" : 68
},
"end_location" : {
"lat" : 12.9569421,
"lng" : 77.70609429999999
},
"html_instructions" : "Head \u003cb\u003esouth\u003c/b\u003e on \u003cb\u003ePFS Driveway\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eRestricted usage road\u003c/div\u003e",
"polyline" : {
"points" : "wabnAo~gyMzK_AH?D#DD#F?F#N?D#J#D?F#D"
},
"start_location" : {
"lat" : 12.959155,
"lng" : 77.70615509999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "26 m",
"value" : 26
},
"duration" : {
"text" : "1 min",
"value" : 6
},
"end_location" : {
"lat" : 12.9567068,
"lng" : 77.70613229999999
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e to stay on \u003cb\u003ePFS Driveway\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eRestricted usage road\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "{sanAa~gyMl#G"
},
"start_location" : {
"lat" : 12.9569421,
"lng" : 77.70609429999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.1 km",
"value" : 138
},
"duration" : {
"text" : "1 min",
"value" : 59
},
"end_location" : {
"lat" : 12.9568247,
"lng" : 77.70486409999999
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eMarathalli Bridge Service Rd\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "mranAi~gyMC^Q|E"
},
"start_location" : {
"lat" : 12.9567068,
"lng" : 77.70613229999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "36 m",
"value" : 36
},
"duration" : {
"text" : "1 min",
"value" : 8
},
"end_location" : {
"lat" : 12.9565042,
"lng" : 77.70486959999999
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eMunnekollal Main Rd\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "csanAkvgyM~#A"
},
"start_location" : {
"lat" : 12.9568247,
"lng" : 77.70486409999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.5 km",
"value" : 482
},
"duration" : {
"text" : "1 min",
"value" : 83
},
"end_location" : {
"lat" : 12.9563276,
"lng" : 77.7091214
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eMarathalli Bridge Service Rd\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "cqanAmvgyMPkGFuCV_GHeB?K#CDWD]g#C"
},
"start_location" : {
"lat" : 12.9565042,
"lng" : 77.70486959999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.8 km",
"value" : 838
},
"duration" : {
"text" : "2 mins",
"value" : 142
},
"end_location" : {
"lat" : 12.956896,
"lng" : 77.70141439999999
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eMarathalli Bridge/Old Airport Rd/Varthur Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinue to follow Old Airport Rd/Varthur Rd\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "apanA_qhyMs#nVE|A?#AB?#ErBInAG~BMlCA^ARC^CR?B?#?r#AXA`#"
},
"start_location" : {
"lat" : 12.9563276,
"lng" : 77.7091214
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.4 km",
"value" : 411
},
"duration" : {
"text" : "1 min",
"value" : 62
},
"end_location" : {
"lat" : 12.9533531,
"lng" : 77.7003715
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e toward \u003cb\u003eNH7\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "ssanAy`gyMRJHDFDvBb#xBf#ZHpK`B"
},
"start_location" : {
"lat" : 12.956896,
"lng" : 77.70141439999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "31 m",
"value" : 31
},
"duration" : {
"text" : "1 min",
"value" : 23
},
"end_location" : {
"lat" : 12.9531397,
"lng" : 77.7001892
},
"html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e toward \u003cb\u003eNH7\u003c/b\u003e",
"maneuver" : "turn-slight-right",
"polyline" : {
"points" : "m}`nAizfyMHF^Z"
},
"start_location" : {
"lat" : 12.9533531,
"lng" : 77.7003715
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "3.8 km",
"value" : 3796
},
"duration" : {
"text" : "6 mins",
"value" : 373
},
"end_location" : {
"lat" : 12.9274228,
"lng" : 77.6798031
},
"html_instructions" : "Slight \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003eNH7\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by VIMS Super Specialty Hospital (on the left in 550 m)\u003c/div\u003e",
"maneuver" : "turn-slight-left",
"polyline" : {
"points" : "c|`nAeyfyM`Ft#lBRzFl#|Fj#x#JzATn#J`AR~A`#fB`#dB`#j#Ph#PhKdCr#R^HVJZJ`#Nb#RdAh#bAf#x#`#r#X\\N`#PtAp#pBdA~#f#`Ah#lAx#`Av#n#n#xB|BfBpBb#f#fBtBtDdE`AdAbCpC`CjCtC`DpIlJxF|G^h#PTNXXf#\\r#Th#p#dBl#~AjA~CxA~Dx#zBVp#p#hBr#hBJR"
},
"start_location" : {
"lat" : 12.9531397,
"lng" : 77.7001892
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "3.0 km",
"value" : 3010
},
"duration" : {
"text" : "5 mins",
"value" : 270
},
"end_location" : {
"lat" : 12.9237183,
"lng" : 77.6540827
},
"html_instructions" : "Keep \u003cb\u003eleft\u003c/b\u003e to stay on \u003cb\u003eNH7\u003c/b\u003e",
"maneuver" : "keep-left",
"polyline" : {
"points" : "k{{mAwybyMRf#rBxFbD|I^~#\\~#~C`I^jAX|#Vv#zAnEfBlF|#~BvAbEtBfFZ|#hFbNT~##J?J#J#J?L?JAL?LAJAJCLALEREXe#hC_AnEMr#Kn#a#xC]bCa#zBk#lCaA|D_AfD_AvDc#fBYrAMx#OlAe#vD"
},
"start_location" : {
"lat" : 12.9274228,
"lng" : 77.6798031
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.4 km",
"value" : 438
},
"duration" : {
"text" : "1 min",
"value" : 66
},
"end_location" : {
"lat" : 12.924442,
"lng" : 77.6501267
},
"html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e at \u003cb\u003eAgra Exit\u003c/b\u003e toward \u003cb\u003eSarjapur Main Rd\u003c/b\u003e",
"maneuver" : "turn-slight-right",
"polyline" : {
"points" : "gd{mA_y}xMQb#Mv#QtAu#rGYjCCXCXA\\AXAP?P?r#"
},
"start_location" : {
"lat" : 12.9237183,
"lng" : 77.6540827
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "1.8 km",
"value" : 1816
},
"duration" : {
"text" : "5 mins",
"value" : 304
},
"end_location" : {
"lat" : 12.9248137,
"lng" : 77.63406830000001
},
"html_instructions" : "Slight \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eSarjapur Main Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Karthikshekar Hospital (on the left in 1.3 km)\u003c/div\u003e",
"maneuver" : "turn-slight-right",
"polyline" : {
"points" : "wh{mAi`}xMEDCDEFCFA#I`#I\\?#AV?R#|#?JD~#Dx#Bl#DtB#TDx#Dd#?NDz#?P#L?V?l#?nC#^#\\#P#H#DFTx#jD\\jBf#jC`#fCVjADVDP#H?H?JAH?FADADADCFCHmArEEL_BpFCHA#ADGJIRKPW`#[f#S^Wl#KXEJCJA#AHCFCHAHERCNANAPAD?F?F#PBVNtAPxB`#lELbA"
},
"start_location" : {
"lat" : 12.924442,
"lng" : 77.6501267
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "77 m",
"value" : 77
},
"duration" : {
"text" : "1 min",
"value" : 44
},
"end_location" : {
"lat" : 12.9250061,
"lng" : 77.6335821
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003e80 Feet Main Rd/Mahatyagi Laksmidevi Rd\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "ak{mA}{yxMFfA#PSB]B"
},
"start_location" : {
"lat" : 12.9248137,
"lng" : 77.63406830000001
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.6 km",
"value" : 579
},
"duration" : {
"text" : "2 mins",
"value" : 101
},
"end_location" : {
"lat" : 12.9245984,
"lng" : 77.62833669999999
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003e1st Cross Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Sandeepani (on the right)\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "il{mA{xyxMDb#VdCL~APzBz#hILzBCh#Gl#i#rB"
},
"start_location" : {
"lat" : 12.9250061,
"lng" : 77.6335821
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.2 km",
"value" : 174
},
"duration" : {
"text" : "1 min",
"value" : 37
},
"end_location" : {
"lat" : 12.9261219,
"lng" : 77.628711
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003e8th Main Rd\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "wi{mAcxxxM_Dk#uBYYC"
},
"start_location" : {
"lat" : 12.9245984,
"lng" : 77.62833669999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.3 km",
"value" : 264
},
"duration" : {
"text" : "1 min",
"value" : 58
},
"end_location" : {
"lat" : 12.9270734,
"lng" : 77.6264824
},
"html_instructions" : "Turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003e3rd Cross Rd\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "gs{mAmzxxMe#zAe#xA}#lCs#xB"
},
"start_location" : {
"lat" : 12.9261219,
"lng" : 77.628711
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0.1 km",
"value" : 111
},
"duration" : {
"text" : "1 min",
"value" : 46
},
"end_location" : {
"lat" : 12.9280212,
"lng" : 77.6267905
},
"html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003e12th Main Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by the park (on the right)\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "ey{mAolxxM}D}#"
},
"start_location" : {
"lat" : 12.9270734,
"lng" : 77.6264824
},
"travel_mode" : "DRIVING"
}
],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "wabnAo~gyMdL_AJFBd#BX#Dl#GU|F~#APkG^uKHqBF[D]g#Cy#lYAFErBInAUlGKfBArAA`#RJPJpFjAlLjBh#b#`Ft#lBRxNxAtC`#pB^fEbApCr#rLvCfCt#dAb#hCpAlD|AfEvB`CpAlAx#`Av#hDlDhLtM|MdOpIlJxF|Gp#~#h#`Ar#|AdGdPvD`K^z#vGvQ|#~B~C`I^jAp#tBbE|LtCbIpCdHhFbNT~##VBp#Er#QhAeBxIYbB_A|Ga#zBk#lCaA|D_AfDcB~Gg#lCu#dGQb#Mv#gAhJ]dDEv#CpBSZUbA?tBJxBHbDLdCFrB?|DB|#BZHZvAvGhArGd#~BAf#IXwD|MO\\iAnBk#lAQd#K^Ov#En#Dp#pA`NHxAq#F|#dKz#hILzBKvAi#rB_Dk#oC]}D|L}D}#"
},
"summary" : "NH7",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}
Required JSON for some application:-
{
"geocoded_waypoints" : [
{
"geocoder_status" : "OK",
"place_id" : "ChIJbZ--gzESrjsRsmxa_tmvhlI",
"types" : [ "route" ]
},
{
"geocoder_status" : "OK",
"place_id" : "Elk4NjksIDEydGggTWFpbiBSb2FkLCBLb3JhbWFuZ2FsYSAzIEJsb2NrLCBLb3JhbWFuZ2FsYSwgQmVuZ2FsdXJ1LCBLYXJuYXRha2EgNTYwMDM0LCBJbmRpYQ",
"types" : [ "street_address" ]
}
],
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 12.959155,
"lng" : 77.7091214
},
"southwest" : {
"lat" : 12.9206335,
"lng" : 77.6264824
}
},
"copyrights" : "Map data ©2015 Google",
"legs" : [
{
"distance" : {
"text" : "12.5 km",
"value" : 12510
},
"duration" : {
"text" : "29 mins",
"value" : 1750
},
"end_address" : "869, 12th Main Road, Koramangala 3 Block, Koramangala, Bengaluru, Karnataka 560034, India",
"end_location" : {
"lat" : 12.9280212,
"lng" : 77.6267905
},
"start_address" : "PFS Driveway, Lakshminarayana Pura, AECS Layout, Marathahalli, Bengaluru, Karnataka 560037, India",
"start_location" : {
"lat" : 12.959155,
"lng" : 77.70615509999999
},
}
],
"overview_polyline" : {
"points" : "wabnAo~gyMdL_AJFBd#BX#Dl#GU|F~#APkG^uKHqBF[D]g#Cy#lYAFErBInAUlGKfBArAA`#RJPJpFjAlLjBh#b#`Ft#lBRxNxAtC`#pB^fEbApCr#rLvCfCt#dAb#hCpAlD|AfEvB`CpAlAx#`Av#hDlDhLtM|MdOpIlJxF|Gp#~#h#`Ar#|AdGdPvD`K^z#vGvQ|#~B~C`I^jAp#tBbE|LtCbIpCdHhFbNT~##VBp#Er#QhAeBxIYbB_A|Ga#zBk#lCaA|D_AfDcB~Gg#lCu#dGQb#Mv#gAhJ]dDEv#CpBSZUbA?tBJxBHbDLdCFrB?|DB|#BZHZvAvGhArGd#~BAf#IXwD|MO\\iAnBk#lAQd#K^Ov#En#Dp#pA`NHxAq#F|#dKz#hILzBKvAi#rB_Dk#oC]}D|L}D}#"
},
"summary" : "NH7",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
}
Omitting parts of the JSON response is not a functionality in the APIs.
If you wish to request this, please do so in the issue tracker:
https://code.google.com/p/gmaps-api-issues/issues/entry?template=Directions%20API%20-%20Feature%20Request
However, I wouldn't expect this to be ever part of the API. For one thing, it sounds like it'd be of limited use, and it can be implemented in your own server: proxy requests to the API, then trim responses.
Perhaps you could also use SPDY:
https://developers.google.com/speed/spdy/