How to get parse json - SwiftyJSON - json

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.

Related

Google Places API returning strange results

I am using google places API to return basic information about businesses such as
- name
- address
- phone
and maybe images later but even the above 3 would be great initially.
The results being returned don't seem to be as accurate as when I search in google maps. For example, if I search for 'florist Athlone' in the town Athlone in Ireland I get 4 results, all are clearly florists.
However, if I use google places API and use Athlone as the coordinates like this with florist as the keyword
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=53.4232693,-7.9490146&radius=8000&name=nail%20salon&key=x
It returns weird results such as a shopping centre, a marketing company, a photographer etc. Now it does correctly return the 4 florists but is there a way via places or another API that can return more accurate results.
Obviously, if someone is looking for a florist and they see a marketing company and a photographer, the information looks reliable. What I like about places is that it gives 150,000 searches a day free. Ideally, the suggested API or method would also have a decent free plan.
This is just one example but there are tons of examples for all types of business categories where the info being returns is not accurate. I also thought about using the type value but that doesn't seem great. For example, you cant pass b&b you have to pass lodging which is too broad and I need to return specific categories like pub, restaurant, b&b, butcher etc
{
"html_attributions" : [],
"results" : [
{
"geometry" : {
"location" : {
"lat" : 53.4242032,
"lng" : -7.934448300000001
},
"viewport" : {
"northeast" : {
"lat" : 53.42555302989273,
"lng" : -7.933098470107277
},
"southwest" : {
"lat" : 53.42285337010728,
"lng" : -7.935798129892721
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "4e0ff98af928a212bcd64e35c25278c7a962b1e0",
"name" : "A Room in Bloom",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 2368,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/113110406294245292993/photos\"\u003eGary Kearney\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAm5vmwNVndTiIiDiX-fGVhB-8aTx7Kyp4qMucuvcc80DMhGpn6nG0Q3DBK9_5jqT7fZDIctw-KHJ89RE_D2sJj5xr4Sy6zAYlVnyJx7VbRMqpHKY3Mr_eKmFTvnDKhP4CEhChU8nLg8ikqfsCcXukqoKGGhRVNPN5GdlO-KNWYgg3W3sLp-GiWg",
"width" : 4208
}
],
"place_id" : "ChIJQ-Uh0wVJXEgRHwfLO-9Qe_0",
"plus_code" : {
"compound_code" : "C3F8+M6 Athlone, County Westmeath, Ireland",
"global_code" : "9C5JC3F8+M6"
},
"rating" : 4.6,
"reference" : "CmRbAAAAVbtKUhG5syxA1oSfs3xvlsZtRfM9CijH13Hml4lPi3xdNwN-Pvs3KJRQ5wd0ZBdFI1G5d3VaaZm0lQVqulKIBqc2DLul2X2eeDaTVQFV84X0WX9xkflqORHVsdoabZCrEhDeR78yzfbmWMpF6Mtml2QkGhRTtjvPgqdoaQNCklJy416Gb2094Q",
"scope" : "GOOGLE",
"types" : [ "florist", "store", "point_of_interest", "establishment" ],
"vicinity" : "Fairview Terrace, Garden Vale, Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.4230177,
"lng" : -7.949603499999998
},
"viewport" : {
"northeast" : {
"lat" : 53.42436752989271,
"lng" : -7.948253670107275
},
"southwest" : {
"lat" : 53.42166787010727,
"lng" : -7.950953329892719
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "d0a8341c1a26a933c926b94227f7e185954337c8",
"name" : "Dooley's Westend Flowers",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 3024,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/110208982636998757346/photos\"\u003eDooley's Westend Flowers\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAQEyT0e3Fi2X7GdSDWaS4NaQoPhq1WGr9KVJoqFnuRSEbGr07sEToiAtP0Jqo2IsOdpBTGY99kLThSO88D0ySco5zbVYG40vxIA-TOlgMP4nXAJKvgJPNzsRE6u05gbyeEhAKodedRy7xMHLiJ3BGu0pjGhQ7veW7qSB13wxp84JzJNhc2Y_2Jg",
"width" : 4032
}
],
"place_id" : "ChIJ5RDhM_xIXEgRUfEQvO3MJEw",
"plus_code" : {
"compound_code" : "C3F2+65 Athlone, County Westmeath, Ireland",
"global_code" : "9C5JC3F2+65"
},
"rating" : 4.8,
"reference" : "CmRbAAAAeJhLEAtKzEaZ3BsoVcYdcD0mK35nmagxtMRDTkEXitI2eR_fS90rsUr65sp13YlLugzeLkC-fJQrvJfbZ9FzO0DhyjyQiifsI_SdttCNflNQoumRh0-JENcgXqWFd_wUEhDPqZJvkyl4d3HRHpa5UzNLGhQ081hZgVh0M36W2PutZOnYlsJ6Hw",
"scope" : "GOOGLE",
"types" : [
"florist",
"grocery_or_supermarket",
"home_goods_store",
"store",
"food",
"point_of_interest",
"establishment"
],
"vicinity" : "Magazine road, Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.4202395,
"lng" : -7.933982299999999
},
"viewport" : {
"northeast" : {
"lat" : 53.42158932989273,
"lng" : -7.932632470107277
},
"southwest" : {
"lat" : 53.41888967010728,
"lng" : -7.935332129892721
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "335dbc850f70f158aa2023c2f9d894bad2f069eb",
"name" : "Dooley's",
"opening_hours" : {},
"photos" : [
{
"height" : 4032,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/111352362883151837153/photos\"\u003eMichael Carty\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAor8kyir_1aeJsWXo92PDIl4gNUpql3bGKUeXlH2zo8Uq8QfkOPQS0jwQ_nhuz4UzP1crIPY0wKtajgSQPxlgugNNJW9UOKrAS8-mxghnsfnVE__sDl9ZWWLj8MhRDRKzEhDaCNN-80IOdpWEgWk6hdrAGhQ0_CrCoKsLXQTSFcc1nt5ADx0ifQ",
"width" : 3024
}
],
"place_id" : "ChIJY-Qc2QRJXEgREay8iXABhMM",
"plus_code" : {
"compound_code" : "C3C8+3C Athlone, County Westmeath, Ireland",
"global_code" : "9C5JC3C8+3C"
},
"rating" : 4.6,
"reference" : "CmRbAAAAtHL-8kOfiQcsIBrN81TotZ7IcnEw72N38f7q68cz-W55e5Z-VhIF5R7ZLG9dLy3XZkzIqOZC7w4k-w4UbB5YDIP89qmR_Ety4uMjf0D8ueF_pPsLPib9S_JipDt-kS-gEhAPFiIBWm0mitDS0rdQngO_GhQfb2qa7KMqK6Y76wW8og01gjbrFA",
"scope" : "GOOGLE",
"types" : [ "florist", "store", "point_of_interest", "establishment" ],
"vicinity" : "Golden Island (Kilmaine), Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.4232928,
"lng" : -7.9396458
},
"viewport" : {
"northeast" : {
"lat" : 53.42463542989272,
"lng" : -7.938276270107278
},
"southwest" : {
"lat" : 53.42193577010728,
"lng" : -7.940975929892722
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "66ba2e9350b7d1cd1183c3a278e9946d1e21d0fe",
"name" : "Be Floral",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 1440,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/109574484271593171379/photos\"\u003eA Google User\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAEdHCug6ZcEp839GOoVYKUbWZqeW75DRzStWllllUzRHxmUtBObCmf6kajw6b-nK2aDlSamdKVFAAnWFyU7i4GoATn1JbVz0zRWGI0rmbZdyKQHKbxneo32tT_Pl3HsfPEhAeWIUO2lh-FaI8_Bxr2YwQGhQxy9LgWUd8ckYg3eV-IJJ-uEndPg",
"width" : 1920
}
],
"place_id" : "ChIJ0SZ17ANJXEgR-5UdcJuIpM4",
"plus_code" : {
"compound_code" : "C3F6+84 Athlone, County Westmeath, Ireland",
"global_code" : "9C5JC3F6+84"
},
"rating" : 0,
"reference" : "CmRbAAAAujL-64C9k6SPSYVmc8RlqQXJBxPvviqqvzgb40ZJAz8kX4wWuqB_HWUO5D6VyTbSfMaUCa02hjVnRNzr9ISM_CdjkmIrNp2akwv7NznYDgF1o9xTGCMluuTT1MtpmFg3EhBS7eM287v1nw-30wu5IN-sGhTqZfI5f-qny12YPXJuvioHSwD-6g",
"scope" : "GOOGLE",
"types" : [ "florist", "store", "point_of_interest", "establishment" ],
"vicinity" : "Lloyd's Ln, Loughanaskin, Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.43007069999999,
"lng" : -7.8923063
},
"viewport" : {
"northeast" : {
"lat" : 53.43142052989272,
"lng" : -7.890956470107278
},
"southwest" : {
"lat" : 53.42872087010728,
"lng" : -7.893656129892721
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "559974f9849741660baafdbd433c5cb934f2f411",
"name" : "Floral Cloud",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 609,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/105597253291213300228/photos\"\u003eA Google User\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAe-lw4ZpD_fbD5MTBOoKUOpYCYNTboDxFuu1r_j6elTPIu1_QMrZqzqBYzGf8iirE_feDjzeT6XRRWhTjNbaIBja500_FhA3zTAmibm0HFIoBHDhIGMRdWGfsMsypANB8EhC96QUKzxF5ez38wBflj0gZGhQrXVbi4WDiXebfOmjGVJ4EwFd4bA",
"width" : 1084
}
],
"place_id" : "ChIJMdt-IoFIXEgRmdwzL8HC50Y",
"plus_code" : {
"compound_code" : "C4J5+23 Athlone, County Westmeath, Ireland",
"global_code" : "9C5JC4J5+23"
},
"rating" : 4.3,
"reference" : "CmRbAAAAkRrSGSx0ignasWUpJgWiSPgqqTpbr6ATUy3t-61nqH7FCvpnYmn1784H_CCfCzrSt_1uMrNwPHXRbmjFtbUuG5HAeWA7Db1Pu9G2SK9nvJTWbY6FzvOnjHU0sT2AexqmEhBAIgDxoWfQa9Sw9Pw-GIQVGhRY4qzIaUnfCPRW5HFwu3HEOmsqYA",
"scope" : "GOOGLE",
"types" : [ "point_of_interest", "establishment" ],
"vicinity" : "Unit 50, Blyry Industrial Estate, Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.406841,
"lng" : -7.938007
},
"viewport" : {
"northeast" : {
"lat" : 53.40819082989272,
"lng" : -7.936657170107278
},
"southwest" : {
"lat" : 53.40549117010728,
"lng" : -7.939356829892722
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "ba1b851568d90d433d8fc18a0ddda3446b7d962a",
"name" : "Patricias Wedding Treasures",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 480,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/117902390620131484671/photos\"\u003ePatricias Wedding Treasures\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAkEmZoNaP4hqXcTH-3qKlyHNh5KQ3b05D3hASuqJ_oCOjnF0sBoBEGiM_AW111Kd60iwAX3GZMFTbvIB4Fhlg3OcIAlQiZWCBNuSpyUyhi1588s2MJgby7z5amSaGHf3hEhDq2CP7jIbbN6DQjnvHAC8mGhS_U7aX-r_BNy9V0iXMWfv5Wiez1A",
"width" : 640
}
],
"place_id" : "ChIJu5v_RyBJXEgRGM1aYEvmD0w",
"plus_code" : {
"compound_code" : "C346+PQ Golden Island, County Westmeath, Ireland",
"global_code" : "9C5JC346+PQ"
},
"rating" : 0,
"reference" : "CmRbAAAAd1bct3aUQYrpSsnHs-DOedUAPYl9FuUO4P9blXwvSt21rhkm8-IoJkrFUtjRaSdD0S8UW9tnTEvienOZAJ86Wq8Ypeb5ylubHrmdBlmP8oFNHe6SDITXJ6JDcMp2L_UQEhDoSKhOwIsY1VI0VIVtv5NuGhSP45FmfICFqvJpZCPQ0bfSolwgEA",
"scope" : "GOOGLE",
"types" : [ "point_of_interest", "establishment" ],
"vicinity" : "Golden Island, Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.4239152,
"lng" : -7.989224200000001
},
"viewport" : {
"northeast" : {
"lat" : 53.42556182989272,
"lng" : -7.988307570107279
},
"southwest" : {
"lat" : 53.42286217010728,
"lng" : -7.991007229892722
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "abe41b107c9ab2fd16763225006b0072cf06f393",
"name" : "Liam Kidney Photography",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 1536,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/100645956983550164138/photos\"\u003eLiam Kidney\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAA0ZHwKonfbiEuX-zDNs2_U9704br-fmS9gqazgzajJ6j9_kzFTrY_qgVZlHF9UyaLKq-KvmRcaPpUAY0ILOljInTdTeQC_aZ7MHWEnNHEXoeHIT3EGAODZm9rREBRaMMLEhBziDTx76q3EzTrDKtyx-cTGhThlbSNYNPIDz5IBkW900I0n6RAdg",
"width" : 2048
}
],
"place_id" : "ChIJL-WIf4hIXEgRTNE0T8MZBHQ",
"plus_code" : {
"compound_code" : "C2F6+H8 Monksland, County Roscommon, Ireland",
"global_code" : "9C5JC2F6+H8"
},
"rating" : 5,
"reference" : "CmRbAAAAinNcXzE02soMQisE8PC-LLmbXYXBh74SfpSEw4ODJghp8EGcA7E7zXoVxNG3xvLaRYCWk8h9qcQBqnqP6Oxzo3n0VcmbS5C0DJZs43NxFgLApnCPl8A85Gz7eynzaRWhEhDZfmuxwQCF4GfmiSz3j3GfGhQ8Za_ZMlHa1wmSHRPVtoIUEheg8w",
"scope" : "GOOGLE",
"types" : [ "point_of_interest", "establishment" ],
"vicinity" : "50 Ross Árd, Monksland, Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.4763658,
"lng" : -7.898927199999999
},
"viewport" : {
"northeast" : {
"lat" : 53.47771562989273,
"lng" : -7.897577370107276
},
"southwest" : {
"lat" : 53.47501597010729,
"lng" : -7.900277029892719
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/lodging-71.png",
"id" : "202c490aa76d1fe877bae7b2a9b62e27ae2d187b",
"name" : "Glasson Hotel & Golf Club",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 2322,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/113442176282980152058/photos\"\u003emarcus 187\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAUEX6VhfjaGdoaCbY1iI0sPx3ja2hU5CAB6JJB5DJ1idsc4Mdw3kJFnS2Mtqx61Ty9neRMR0Red0uyFu-gamqP_IHDsW_IaOenM1DT-vOqL8kpwakU0dvDm8WaCOn8eSOEhAqWy96iezK2c2opTlx2e_DGhSUD5-FiYnBkobMOOlN9trbk5Cogw",
"width" : 4128
}
],
"place_id" : "ChIJrVOmAudJXEgRIqez0LFZyHI",
"plus_code" : {
"compound_code" : "F4G2+GC Killinure South, County Westmeath, Ireland",
"global_code" : "9C5JF4G2+GC"
},
"rating" : 4.5,
"reference" : "CmRbAAAA26_DiJ5XJ-sty-_bpm0A9X-UW6ftcB07mXCixo6e9Gqgqq4FslRqWzcBNJAWbmmhug_c1MorfCiQF52kJXNOxc-6X_fM2E-q853tp4F5OjzuxicBBK3AoOWcj73RwS2XEhBS2cSBMLVD84D4CPMaBtseGhQPEgR2oR-prQkK98Aj0nL1R1xSrg",
"scope" : "GOOGLE",
"types" : [
"bar",
"lodging",
"restaurant",
"food",
"point_of_interest",
"establishment"
],
"vicinity" : "Killinure Cottage, Killinure, Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.430479,
"lng" : -7.893891
},
"viewport" : {
"northeast" : {
"lat" : 53.43182882989272,
"lng" : -7.892541170107278
},
"southwest" : {
"lat" : 53.42912917010727,
"lng" : -7.895240829892722
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "b9a92eaa8780cc6b38232d20d0da5617c70e0304",
"name" : "FCDM - Full Circle Digital Marketing",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 607,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/112102288553428624320/photos\"\u003eFCDM\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAlL1f48FXqYsCZgyqjCajqxFR5jq-48nv5AakzESAYlqk-kbeR1Zg4QayQtt74KUS6e_UTWdnD0DDFmTYDrtPZVqmj2Tjl4rABDJh1X9AOMF8A1QlrpqcR5Nky_7BQ-55EhCnXVkSGDC-dZP1rmp9iiFYGhQ0a1AbzgrnREnUOBcVsFh7XSebPg",
"width" : 1080
}
],
"place_id" : "ChIJo0nTMY9IXEgRElwEQnqwbmI",
"plus_code" : {
"compound_code" : "C4J4+5C Athlone, County Westmeath, Ireland",
"global_code" : "9C5JC4J4+5C"
},
"rating" : 3.7,
"reference" : "CmRbAAAAkUitIdEDXa-ieKhT6AtJyTNUHWu4-x950qE5sPwujFW5-m65iSaYmx_QORopdZtyzIIZtxrmBeDHN3FA0LAXQxi3Blh5wpq1fkQDw4135pm9cYyIC4RIYMz2utgjvx1hEhC7PxyDVuZQw6GqjT3zZDgsGhS2sC-UlbjDCtkr4OVQQoRv1trv9Q",
"scope" : "GOOGLE",
"types" : [ "point_of_interest", "establishment" ],
"vicinity" : "Unit 50, Blyry Business and Commercial Park., Athlone"
},
{
"geometry" : {
"location" : {
"lat" : 53.4204895,
"lng" : -7.9342238
},
"viewport" : {
"northeast" : {
"lat" : 53.42183932989272,
"lng" : -7.932873970107278
},
"southwest" : {
"lat" : 53.41913967010728,
"lng" : -7.935573629892722
}
}
},
"icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
"id" : "624d46cc4c06746da8bc9bd616f1844b63ab269b",
"name" : "Golden Island Shopping Centre",
"opening_hours" : {
"open_now" : true
},
"photos" : [
{
"height" : 2268,
"html_attributions" : [
"\u003ca href=\"https://maps.google.com/maps/contrib/109922865072642849852/photos\"\u003eBongani Mashengele\u003c/a\u003e"
],
"photo_reference" : "CmRaAAAAAO7ai7tjnPI3wUyM_0tsVR7FlnxXrglecFW9hAKDFwjvmIBSxk9c2NvaAEQjCXl4WRU-h09jwm1-kq1dSIgYudW8tr_d9wxvUtIOTq1oz5BW6zv7HMZS8UeIVYV6dEwsEhBoJBgWrCHQW-OMaWDdUipbGhT11E8yQvzX8Tu-_AIEVXVJrhYHoQ",
"width" : 4032
}
],
"place_id" : "ChIJbeXe5wRJXEgRcysPAxpgOX8",
"plus_code" : {
"compound_code" : "C3C8+58 Athlone, County Westmeath, Ireland",
"global_code" : "9C5JC3C8+58"
},
"rating" : 4.3,
"reference" : "CmRbAAAA4PYRNntFEbQ5Bbg9Bzzp9lncwKQOEccTsZ8zLqmdlh5mK0j-7wUCZNjmomBvXcAG_EVvR6wEeaAFkRvs704nZvoBYfbYa2NqAzsF_S2maj-ZyNGrSdaMWsqoXNF3a1vUEhALSMQDnpJUHuIxvQh5U_2PGhRQA_QuMGa5WorYG9eeh0KBpuQfhg",
"scope" : "GOOGLE",
"types" : [ "shopping_mall", "point_of_interest", "establishment" ],
"vicinity" : "Golden Island, Golden Island (Kilmaine), Athlone"
}
],
"status" : "OK"
}
Use
input=nail%20salon
In the url you provided replacing
name=nail%20salon
Have you tried using the Google's API nearbySearch(...) function? That function allows you to specify three parameters: Location (latitude, longitude coordinates), radius (around Location) & type (the type is the keyword here, because based on this Google's API will determine the search results).
var SearchPlaces = {
GPMHotels: ['hotel']
, GPMCoffeeShop: ['cafe']
, GPMFoodPlaces: ['restaurant']
, GPMShoppingPlaces: ['shopping_mall']
};
var service = new google.maps.places.PlacesService(GPMap);
function SearchGPMapServiceNearPlacesFn(service) {
function GetHTML(place) {
var distance = "";
if (place.geometry && place.geometry.location) {
var fromLatLng = new google.maps.LatLng(GPMapLocation.lat, GPMapLocation.lng);
distance = google.maps.geometry.spherical.computeDistanceBetween(fromLatLng, place.geometry.location);
distance = Math.ceil(distance).toLocaleString('#languaje');
}
var html = "* " + (distance ? distance + " m. " : "") + place.name + ". "
+ place.formatted_address + ". " +
(place.international_phone_number || "");
return html;
}
function GetPlaceDetails(place_id) {
if (!place_id) return;
service.getDetails({
placeId: place_id
}, function (place, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
//-->> console.log({ fn: 'GetPlaceDetails', item: place });
$("#GPMNearSitesList").append($('<li>').html(GetHTML(place)));
}
});
}
service.nearbySearch({
location: GPMapLocation,
radius: GPMapOptions.searchRadiusList,
},
function (results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
GetPlaceDetails(results[i].place_id);
//-->>console.log({ fn: "SearchGPMapServiceNearPlacesFn", item: results[i] });
}
}
});
}
See: https://developers.google.com/places/web-service/search
Looking at https://developers.google.com/places/web-service/search it seems that name is not a valid parameter. I suspect it is being ignored. Try using input instead:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=53.4232693,-7.9490146&radius=8000&input=nail%20salon&key=x

Google Directions API transit returns always "ZERO_RESULTS"

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.

google maps directions return to origin

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!

Google Map JSON for low bandwidth networks

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/

How to display "Google API directions" polylines with leaflet?

I would like to display an itinerary on a map with leaflet.
For this, I make a get request on the Google maps directions API. I get a json like this:
{
"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 51.5103406,
"lng" : -0.0627423
},
"southwest" : {
"lat" : 51.5049264,
"lng" : -0.0898856
}
},
"copyrights" : "Données cartographiques ©2014 Google",
"legs" : [
{
"distance" : {
"text" : "3,0 km",
"value" : 2959
},
"duration" : {
"text" : "7 minutes",
"value" : 427
},
"end_address" : "29 Fowey Close, Londres E1W 2JP, Royaume-Uni",
"end_location" : {
"lat" : 51.5064421,
"lng" : -0.0627423
},
"start_address" : "8 Southwark Street, Londres SE1 1TL, Royaume-Uni",
"start_location" : {
"lat" : 51.5049264,
"lng" : -0.0898856
},
"steps" : [
{
"distance" : {
"text" : "0,6 km",
"value" : 601
},
"duration" : {
"text" : "1 minute",
"value" : 77
},
"end_location" : {
"lat" : 51.5099409,
"lng" : -0.0870841
},
"html_instructions" : "Prendre la direction \u003cb\u003enord-est\u003c/b\u003e sur \u003cb\u003eBorough High St/A3\u003c/b\u003e vers \u003cb\u003eBedale St\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinuer de suivre A3\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eEntrée dans une section à péage\u003c/div\u003e",
"polyline" : {
"points" : "ypjyHxpPCG_#o#QY_AkAE?C?CCQSEGEEMQEEACGGIGeAo#]OA?ECQGGC_#KgHeBqAc#a#Iq#WYG_AUi#OIACAYG"
},
"start_location" : {
"lat" : 51.5049264,
"lng" : -0.0898856
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,2 km",
"value" : 152
},
"duration" : {
"text" : "1 minute",
"value" : 25
},
"end_location" : {
"lat" : 51.50989,
"lng" : -0.0883307
},
"html_instructions" : "Prendre légèrement \u003cb\u003eà gauche\u003c/b\u003e sur \u003cb\u003eArthur St\u003c/b\u003e",
"maneuver" : "turn-slight-left",
"polyline" : {
"points" : "cpkyHf_PGB_#EK?A?I#GFEHAJAJ?Z?V#NBRBPDVBFDHDLDFFFFFJFXL"
},
"start_location" : {
"lat" : 51.5099409,
"lng" : -0.0870841
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,6 km",
"value" : 590
},
"duration" : {
"text" : "1 minute",
"value" : 72
},
"end_location" : {
"lat" : 51.50955829999999,
"lng" : -0.080139
},
"html_instructions" : "Prendre \u003cb\u003eà gauche\u003c/b\u003e sur \u003cb\u003eUpper Thames St/A3211\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinuer de suivre A3211\u003c/div\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "yokyH`gPZ}DFu#Dg#H}#Bk#P_CRsDJuAJiB\\qE#QF_ABiA?i#CUCc#Ce#CWCMAIG_#Ke#Oa#ACQi#Qm#"
},
"start_location" : {
"lat" : 51.50989,
"lng" : -0.0883307
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,5 km",
"value" : 498
},
"duration" : {
"text" : "1 minute",
"value" : 73
},
"end_location" : {
"lat" : 51.5093097,
"lng" : -0.0737046
},
"html_instructions" : "Continuer sur \u003cb\u003eByward St/A100\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinuer de suivre A100\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eSortie de section à péage dans 400 m, au niveau de Minories/A1211\u003c/div\u003e",
"polyline" : {
"points" : "wmkyHzsNG[CWCUAS?E?c#?I?M#u##I#_AFs#Jo#DYBM?G?C?C?K?QAs#A]AaACe#Ae#AQM{ASqAIc#CMa#{BEW?I?K?IBK#GHSHOHOJMHKLMRQVOPU"
},
"start_location" : {
"lat" : 51.50955829999999,
"lng" : -0.080139
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,5 km",
"value" : 472
},
"duration" : {
"text" : "1 minute",
"value" : 54
},
"end_location" : {
"lat" : 51.5090739,
"lng" : -0.06770899999999999
},
"html_instructions" : "Continuer sur \u003cb\u003eMinories/A1203\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eContinuer de suivre A1203\u003c/div\u003e",
"polyline" : {
"points" : "elkyHrkMXc#XYHAJORg#VgAT}#Ry#Nq#FWDOD]B]?W?WASAWM_B]gDEe#Gi#i#uCo#uC"
},
"start_location" : {
"lat" : 51.5093097,
"lng" : -0.0737046
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,3 km",
"value" : 297
},
"duration" : {
"text" : "1 minute",
"value" : 57
},
"end_location" : {
"lat" : 51.5065805,
"lng" : -0.0666981
},
"html_instructions" : "Prendre \u003cb\u003eà droite\u003c/b\u003e sur \u003cb\u003eVaughan Way\u003c/b\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "ujkyHdfL`Ak#VQZYZ_#JSJOJMFGJGJG#ALCHCPC~#?n#AL?`#?p#?\\F"
},
"start_location" : {
"lat" : 51.5090739,
"lng" : -0.06770899999999999
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "0,3 km",
"value" : 272
},
"duration" : {
"text" : "1 minute",
"value" : 41
},
"end_location" : {
"lat" : 51.5068938,
"lng" : -0.0629257
},
"html_instructions" : "Prendre \u003cb\u003eà gauche\u003c/b\u003e sur \u003cb\u003eKennet St\u003c/b\u003e",
"maneuver" : "turn-left",
"polyline" : {
"points" : "c{jyHz_LASASAKCMM]Uo#ESGSAOAQ?SAwAFkB#c#FuCKcBAa#"
},
"start_location" : {
"lat" : 51.5065805,
"lng" : -0.0666981
},
"travel_mode" : "DRIVING"
},
{
"distance" : {
"text" : "77 m",
"value" : 77
},
"duration" : {
"text" : "1 minute",
"value" : 28
},
"end_location" : {
"lat" : 51.5064421,
"lng" : -0.0627423
},
"html_instructions" : "Prendre \u003cb\u003eà droite\u003c/b\u003e sur \u003cb\u003eFowey Close\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003eVotre destination se trouvera sur la droite\u003c/div\u003e",
"maneuver" : "turn-right",
"polyline" : {
"points" : "a}jyHhhKrAANABA#C#G?ECEMG"
},
"start_location" : {
"lat" : 51.5068938,
"lng" : -0.0629257
},
"travel_mode" : "DRIVING"
}
],
"via_waypoint" : []
}
],
"overview_polyline" : {
"points" : "ypjyHxpPc#w#qAeBI?UW_#e#IKoAw#w#[g#OgHeBqAc#sAa#yA]qA[GB_#EM?QHGT?nAFd#H^Xf#RNXLZ}DL}ALiB|#sN^cFJiCC_AGiAQoAo#uBYiAGm#AgADmC\\kC?[EeDEkAOmBcA_GEa#?UDSRc#T]VYj#a#j#y#XYHAJORg#l#eCb#kBLg#H{#?o#Ck#k#gGMoAi#uCo#uCxA}#v#y#Vc#RUVOj#M~CAp#?\\FCg#EYc#mAMg#Ca#AkBHoCFuCKcBAa#rAARCBKCKMG"
},
"summary" : "A3",
"warnings" : [],
"waypoint_order" : []
}
],
"status" : "OK"
};
I see there's some fields polyline with some weird data in it but I don't know what it represents. How can I display these?
That's a Google maps encoded polyline.
You can use this library to decode them at the appropriate resolution:
Polyline decoder (and encoder)
Basically they are an ascii encoded binary structure containing a set of polylines for multiple zoom levels.
You can actually use the Leaflet plugin: Leaflet.encoded . That'll put the Google Encoded Polyline on the Leaflet map.
The polyline data is encoded. I had this same issue creating a rubygem to do more or less the same thing. I came across a script written by a guy named George Lantz that decodes the string into points. I have it included as ruby in my gem here. You can probably figure out the logic in whatever language you prefer.
Ruby Script to Decode GMaps Polyline Data