Search code examples
google-mapsdirections

Google Directions API start_address different from origin in input


My Google Directions API request is:

https://maps.googleapis.com/maps/api/directions/json?origin=41.43206,-81.38992&destination=41.43206,-81.48992&key=xxxxxxxx

The response I receive is:

{
...
 "routes": [
{
  "bounds": {
    "northeast": {
      "lat": 41.4358763,
      "lng": -81.3897891
    },
    "southwest": {
      "lat": 41.4238459,
      "lng": -81.4910838
    }
  },
  "copyrights": "Map data ©2016 Google",
  "legs": [
    {
      "distance": {
        "text": "6.5 mi",
        "value": 10537
      },
      "duration": {
        "text": "14 mins",
        "value": 857
      },
      "end_address": "4743-4753 Country Ln, Warrensville Heights, OH 44128, USA",
      "end_location": {
        "lat": 41.4322651,
        "lng": -81.4910838
      },
      "start_address": "45 Bell St, Chagrin Falls, OH 44022, USA",
      "start_location": {
        "lat": 41.4318382,
        "lng": -81.3897891
      },
      "steps": [
        {
          "distance": {
            "text": "0.1 mi",
            "value": 191
          },
          "duration": {
            "text": "1 min",
            "value": 33
          },
          "end_location": {
            "lat": 41.4311157,
            "lng": -81.3918637
          },
          "html_instructions": "Head <b>southwest</b> on <b>Bell St</b> toward <b>Pleasant Dr</b>",
          "polyline": {
            "points": "_d{{FdmwoNFVRx@bA`EVbAVdA"
          },
          "start_location": {
            "lat": 41.4318382,
            "lng": -81.3897891
          },
          "travel_mode": "DRIVING"
        },
        ...
        {
          "distance": {
            "text": "0.2 mi",
            "value": 317
          },
          "duration": {
            "text": "1 min",
            "value": 32
          },
          "end_location": {
            "lat": 41.4322651,
            "lng": -81.4910838
          },
          "html_instructions": "Turn <b>left</b> onto <b>Country Ln</b><div style=\"font-size:0.9em\">Destination will be on the left</div>",
          "maneuver": "turn-left",
          "polyline": {
            "points": "ix{{FldkpNxJ?x@Ln@PnAX"
          },
          "start_location": {
            "lat": 41.4350887,
            "lng": -81.49079350000001
          },
          "travel_mode": "DRIVING"
        }
      ],
      "traffic_speed_entry": [],
      "via_waypoint": []
    }
  ],
  "overview_polyline": {
    "points": "_d{{FdmwoNvBvIVdAs@`@_Af@cCnAp@vCf@rBlAzEHd@`@nEFz@Cj@Or@{@nBUl@Q|@c@dGVZz@vAxDdGtBnDzCrEhAjCdAnCZ~Ap@bJJ`CAn@X\\\\r@hSx^hAxCn@pBXr@FbR?dCAz@ElAOhBe@xCkBvHqAtF]|BOhBG~BFpOFxBhBt\\r@vMBpA?zH?z\\CV?rV@V?nT?|QBvl@@vI@lJAdI?fDDhODxPHvq@?hB_@EgA?m@@EDyBBmCCqE?{FAkHB}E?cDEwBBcE?cKA_@?VdFl@fMp@pNd@fK@fJApCxJ?hB^nAX"
  }
...
}

Why is the start address in the sole leg different from the origin specified in the request? These two points are 6.5 miles apart.

Same is true for end_address and destination specified in the request.

Thanks, Abhishek Batra


Solution

  • The DirectionsService reverse geocodes any location provided as coordinates, finds the nearest location on the road and uses that as the origin (or destination).

    Your two points both happen to be in the middle of water.

    enter image description here enter image description here