1
votes

When I run the first Google API url with origin, destination and waypoints, it returns

https://maps.googleapis.com/maps/api/directions/json?origin=9.6614981,80.02554649999999&waypoints=6.9040322,79.948803&destination=6.053518500000001,6.053518500000001%7C&sensor=false

{
   "geocoded_waypoints" : [
      {},
      {},
      {
         "geocoder_status" : "ZERO_RESULTS"
      }
   ],
   "routes" : [],
   "status" : "NOT_FOUND"
}

But when I run this second url, this works perfectly fine.

https://maps.googleapis.com/maps/api/directions/json?origin=6.9146871,79.9711348&waypoint=6.9040322,79.948803%7C&destination=6.9058482,79.9248089&sensor=false

{
   "geocoded_waypoints" : [
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJnbKVwttW4joR96eguc1D88A",
         "types" : [ "route" ]
      },
      {
         "geocoder_status" : "OK",
         "place_id" : "ChIJnVoMvVZX4joRcAOUeZGMTUA",
         "types" : [ "street_address" ]
      }
   ],
   "routes" : [
      {
         "bounds" : {
            "northeast" : {
               "lat" : 6.916328699999999,
               "lng" : 79.972351
            },
            "southwest" : {
               "lat" : 6.9033429,
               "lng" : 79.9247644
            }
         },
         "copyrights" : "Map data ©2017 Google",
         "legs" : [
            {
               "distance" : {
                  "text" : "6.9 km",
                  "value" : 6928
               },
               "duration" : {
                  "text" : "18 mins",
                  "value" : 1109
               },
               "end_address" : "19/7 Bogahahena Rd, Sri Jayawardenepura Kotte 10120, Sri Lanka",
               "end_location" : {
                  "lat" : 6.9058178,
                  "lng" : 79.9247644
               },
               "start_address" : "Pasan Mawatha, Malabe, Sri Lanka",
               "start_location" : {
                  "lat" : 6.914893699999999,
                  "lng" : 79.9702508
               },
               "steps" : [
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 167
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 50
                     },
                     "end_location" : {
                        "lat" : 6.916328699999999,
                        "lng" : 79.97066389999999
                     },
                     "html_instructions" : "Head \u003cb\u003enorth\u003c/b\u003e on \u003cb\u003ePasan Mawatha\u003c/b\u003e toward \u003cb\u003eWelivita Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Boys Hostel (on the right)\u003c/div\u003e",
                     "polyline" : {
                        "points" : "aqei@aebgNg@GWEOEUKaAY{AWK?O?"
                     },
                     "start_location" : {
                        "lat" : 6.914893699999999,
                        "lng" : 79.9702508
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "0.2 km",
                        "value" : 202
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 42
                     },
                     "end_location" : {
                        "lat" : 6.915699,
                        "lng" : 79.972351
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e onto \u003cb\u003eWelivita Rd\u003c/b\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "azei@sgbgNBg@BQHc@J[Va@LQHOFOLm@He@No@"
                     },
                     "start_location" : {
                        "lat" : 6.916328699999999,
                        "lng" : 79.97066389999999
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "2.8 km",
                        "value" : 2757
                     },
                     "duration" : {
                        "text" : "7 mins",
                        "value" : 426
                     },
                     "end_location" : {
                        "lat" : 6.903943,
                        "lng" : 79.9549985
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at Petti Kade onto \u003cb\u003eB263\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Super Como Technologies (on the right)\u003c/div\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "cvei@erbgN|@J`@DbAHb@@hBFn@?t@@^?rAAhAA\\AX?b@?R@RBTBPBPDXH\\H\\Jz@X|Cr@LFHBJDNHLDLHLJPJNLJNLNJRLTHTHV|@lC`@fAHTDPDPBJ@J@T@TAVAVCVIb@KZKVO\\KTM`@AJALALAN@RBZDZF^FZFVHPFPFNFDPRJHVNXLrAj@FBn@Zn@XXNVNTLPJXPXVd@b@@@PRZ`@JRL\\Rl@^`AJZDFXp@DLPd@Xn@JVNX\\j@b@p@^l@h@fA\\z@Pb@t@xBVp@ZhAVlANv@ZpADd@BZ@L@d@@TANCTE^Gh@Mp@Qz@APIZI\\EZI`@Ef@Ej@Ef@Gz@Cd@"
                     },
                     "start_location" : {
                        "lat" : 6.915699,
                        "lng" : 79.972351
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "3.7 km",
                        "value" : 3722
                     },
                     "duration" : {
                        "text" : "9 mins",
                        "value" : 564
                     },
                     "end_location" : {
                        "lat" : 6.9052345,
                        "lng" : 79.9251951
                     },
                     "html_instructions" : "At \u003cb\u003eMalabe\u003c/b\u003e, continue onto \u003cb\u003eකෝට්ටේ - බෝපේ පාර\u003c/b\u003e/\u003cb\u003eB240\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Megacity (on the left in 350 m)\u003c/div\u003e",
                     "polyline" : {
                        "points" : "slci@we_gNEj@Cl@CPCTERKZM\\Ql@Wn@Wz@Oz@GZALAN?Z?N@L?HBPBVZnBD\\@L@J@L@H?J?F?HAH?HCFAHEJGLMZKV}@bBUb@s@jAm@jAKPKNOZARQd@Qp@M`@[hASr@a@~AYfA]dAM^CJEFMNOPOHi@Xc@Tc@X_@Tq@h@OLOPQROPEJKRELADERMl@I`@I^I`@APCL?JAP?N@H@RDPBJPh@FNDNFPBH@JBLBNBV?@D\\FrAD~@Bv@@V?R?`@?^?`DAd@An@Cj@EzAAx@A`AAnA@`@@T@TBPFPDNDNFPJVVv@N\\b@hAVr@JXHVFTFTJl@Ff@Fj@B^@V?Z?^?b@?n@ErDChAEl@C^G`@UpAMh@Q~@Ox@EX?TETCLAJAJ?L?H@H@FBDBFDDDFBBJHFBFFLJNFNBJ@RBN@J?V@p@BL@XDXFRFPFVJTLRLPNXTHJJJFNDN@L@NALCPERGVw@~DMf@EPABAJCPAN@L@LDPFLJPHFJHJHPHNLLH^V"
                     },
                     "start_location" : {
                        "lat" : 6.903943,
                        "lng" : 79.9549985
                     },
                     "travel_mode" : "DRIVING"
                  },
                  {
                     "distance" : {
                        "text" : "80 m",
                        "value" : 80
                     },
                     "duration" : {
                        "text" : "1 min",
                        "value" : 27
                     },
                     "end_location" : {
                        "lat" : 6.9058178,
                        "lng" : 79.9247644
                     },
                     "html_instructions" : "Turn \u003cb\u003eright\u003c/b\u003e at okvel auto care onto \u003cb\u003eBogahahena Rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003ePass by Waruna Motors (on the left)\u003c/div\u003e\u003cdiv style=\"font-size:0.9em\"\u003eDestination will be on the right\u003c/div\u003e",
                     "maneuver" : "turn-right",
                     "polyline" : {
                        "points" : "utci@okyfNc@\\IFgAp@"
                     },
                     "start_location" : {
                        "lat" : 6.9052345,
                        "lng" : 79.9251951
                     },
                     "travel_mode" : "DRIVING"
                  }
               ],
               "traffic_speed_entry" : [],
               "via_waypoint" : []
            }
         ],
         "overview_polyline" : {
            "points" : "aqei@aebgN_AMe@QaAY{AW[?Fy@T_Ad@s@P_@VsANo@|@JdBNlCHxE?dDCnALfBd@z@X|Cr@VJv@^^VZ\\Xb@Vj@fAdDj@|APz@Bj@Cn@Mz@Wr@[r@Ol@CZ?b@Hv@Nz@Ph@N`@XXb@XdDxAvBfAj@\\~@z@RTf@t@lAhDv@lBd@fAl@dAbA~AfAbCfA|Cr@zBf@dCZpADd@Dh@Bz@SnBk@zCOx@OhAWtDIxAGf@q@zBo@jBWvAC\\?j@H`Ad@fDBj@Ed@]~@iAzBiAnBuAhCARQd@_@rAkBdHu@xB]`@y@b@gAn@qA~@_@^a@d@Yr@g@bCOlAA`@B\\H\\Xx@Rv@Jv@LpBHvB@lBAfEEzAGtCCpCBv@Df@ZbAvAvDt@zBRbANrADrB?rAI|FIlA]rB_@hBUrA?TETEXAX@RNZ\\XTR^Jz@FhADf@Fl@Nh@RtA`ATVL^B\\E^sArGMr@?\\F^R^TPz@j@^Vc@\\qAx@"
         },
         "summary" : "B263 and කෝට්ටේ - බෝපේ පාර/B240",
         "warnings" : [],
         "waypoint_order" : []
      }
   ],
   "status" : "OK"
}

Whats the difference when comparing both URL's, i can't seem to find any. Please help! I'm trying to draw the routes between both origin and destination through a waypoint. How can I achieve this ?? Thank you!

1
The difference is the decimal point in coordinates you are giving. To get the accurate point, google suggests to use 7 decimal points.Akhil Nair
Check this site: latlong.net. You can also check in google maps. When you search a location, check the link. It contains the coordinates with 7 decimal points. Though you can use 3 or 4 or 5 decimal points. It should be same for both origin and destination coordinates.Akhil Nair
If it made you clear then don't forget to upvote the comment. :PAkhil Nair
Yes, your explanation gave me a clear idea as well. Thank you :)Andrew Jerome Bernard

1 Answers

2
votes

Check your destination Latlng . The first link you are asking navigation from Sri Lanka to Nigeria(6.053518500000001,6.05351850000000). I think you are adding mismatch destination , ie, You are using the same latitude value for longitude also. Check your code.