দূরত্ব ম্যাট্রিক্স API অনুরোধ এবং প্রতিক্রিয়া

একটি দূরত্ব ম্যাট্রিক্স API অনুরোধ নিম্নলিখিত ফর্ম নেয়:

https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters

যেখানে outputFormat নিম্নলিখিত মানগুলির মধ্যে একটি হতে পারে:

  • json (প্রস্তাবিত), জাভাস্ক্রিপ্ট অবজেক্ট নোটেশনে আউটপুট নির্দেশ করে (JSON); বা
  • xml , XML হিসাবে আউটপুট নির্দেশ করে।

কিছু প্যারামিটার প্রয়োজন যখন অন্যরা ঐচ্ছিক। ইউআরএল-এ স্ট্যান্ডার্ড হিসাবে, অ্যাম্পারস্যান্ড ( & ) অক্ষর ব্যবহার করে সমস্ত প্যারামিটার আলাদা করা হয়। সমস্ত সংরক্ষিত অক্ষর (উদাহরণস্বরূপ প্লাস চিহ্ন "+") অবশ্যই URL-এনকোডেড হতে হবে। পরামিতিগুলির তালিকা এবং তাদের সম্ভাব্য মানগুলি নীচে গণনা করা হয়েছে।

Required parameters

  • destinations

    One or more locations to use as the finishing point for calculating travel distance and time. The options for the destinations parameter are the same as for the origins parameter.

  • origins

    The starting point for calculating travel distance and time. You can supply one or more locations separated by the pipe character (|), in the form of a place ID, an address, or latitude/longitude coordinates:

    • Place ID : If you supply a place ID, you must prefix it with place_id: .
    • Address : If you pass an address, the service geocodes the string and converts it to a latitude/longitude coordinate to calculate distance. This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center.
      Note: using place IDs is preferred over using addresses or latitude/longitude coordinates. Using coordinates will always result in the point being snapped to the road nearest to those coordinates - which may not be an access point to the property, or even a road that will quickly or safely lead to the destination. Using the address will provide the distance to the center of the building, as opposed to an entrance to the building.
    • Coordinates : If you pass latitude/longitude coordinates, they they will snap to the nearest road. Passing a place ID is preferred. If you do pass coordinates, ensure that no space exists between the latitude and longitude values.
    • Plus codes must be formatted as a global code or a compound code. Format plus codes as shown here (plus signs are url-escaped to %2B and spaces are url-escaped to %20):
      • global code is a 4 character area code and 6 character or longer local code ( 849VCWC8+R9 is encoded to 849VCWC8%2BR9 ).
      • compound code is a 6 character or longer local code with an explicit location ( CWC8+R9 Mountain View, CA, USA is encoded to CWC8%2BR9%20Mountain%20View%20CA%20USA ).
    • Encoded Polyline Alternatively, you can supply an encoded set of coordinates using the Encoded Polyline Algorithm . This is particularly useful if you have a large number of origin points, because the URL is significantly shorter when using an encoded polyline.
      • Encoded polylines must be prefixed with enc: and followed by a colon : . For example: origins=enc:gfo}EtohhU:
      • You can also include multiple encoded polylines, separated by the pipe character | . For example:
        origins=enc:wc~oAwquwMdlTxiKtqLyiK:|enc:c~vnAamswMvlTor@tjGi}L:|enc:udymA{~bxM:
        

Optional parameters

  • 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.

  • avoid

    Distances may be calculated that adhere to certain restrictions. Restrictions are indicated by use of the avoid parameter, and an argument to that parameter indicating the restriction to avoid. The following restrictions are supported:

    • tolls indicates that the calculated route should avoid toll roads/bridges.
    • highways indicates that the calculated route should avoid highways.
    • ferries indicates that the calculated route should avoid ferries.
    • indoor indicates that the calculated route should avoid indoor steps for walking and transit directions.

    It's possible to request a route that avoids any combination of tolls, highways and ferries by passing both restrictions to the avoid parameter. For example avoid=tolls|highways|ferries .

    Note: The addition of restrictions does not preclude routes that include the restricted feature; it biases the result to more favorable routes.
  • departure_time

    Specifies the desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC. If a departure_time later than 9999-12-31T23:59:59.999999999Z is specified, the API will fall back the departure_time to 9999-12-31T23:59:59.999999999Z. Alternatively, you can specify a value of now, which sets the departure time to the current time (correct to the nearest second). The departure time may be specified in two cases:

    • For requests where the travel mode is transit: You can optionally specify one of departure_time or arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time).
    • For requests where the travel mode is driving: You can specify the departure_time to receive a route and trip duration (response field: duration_in_traffic) that take traffic conditions into account. The departure_time must be set to the current time or some time in the future. It cannot be in the past.
    Note: If departure time is not specified, choice of route and duration are based on road network and average time-independent traffic conditions. Results for a given request may vary over time due to changes in the road network, updated average traffic conditions, and the distributed nature of the service. Results may also vary between nearly-equivalent routes at any time or frequency.
    Note: Distance Matrix requests specifying `departure_time` when `mode=driving` are limited to a maximum of 100 elements per request. The number of origins times the number of destinations defines the number of elements.
  • language

    The language in which to return results.

    • See the list of supported languages . Google often updates the supported languages, so this list may not be exhaustive.
    • If language is not supplied, the API attempts to use the preferred language as specified in the Accept-Language header.
    • The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
    • If a name is not available in the preferred language, the API uses the closest match.
    • The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.
  • mode

    For the calculation of distances and directions, you may specify the transportation mode to use. By default, DRIVING mode is used. By default, directions are calculated as driving directions. The following travel modes are supported:

    • driving (default) indicates standard driving directions or distance using the road network.
    • walking requests walking directions or distance via pedestrian paths & sidewalks (where available).
    • bicycling requests bicycling directions or distance via bicycle paths & preferred streets (where available).
    • transit requests directions or distance via public transit routes (where available). Transit trips are available for up to 7 days in the past or 100 days in the future. If you set the mode to transit, you can optionally specify either a departure_time or an arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). You can also optionally include a transit_mode and/or a transit_routing_preference .
    Note: Both walking and bicycling directions may sometimes not include clear pedestrian or bicycling paths, so these directions will return warnings in the returned result which you must display to the user.
  • region

    The region code, specified as a ccTLD ("top-level domain") two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom's ccTLD is "uk" (.co.uk) while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland").

  • traffic_model

    Specifies the assumptions to use when calculating time in traffic. This setting affects the value returned in the duration_in_traffic field in the response, which contains the predicted time in traffic based on historical averages. The traffic_model parameter may only be specified for driving directions where the request includes a departure_time . The available values for this parameter are:

    • best_guess (default) indicates that the returned duration_in_traffic should be the best estimate of travel time given what is known about both historical traffic conditions and live traffic. Live traffic becomes more important the closer the departure_time is to now.
    • pessimistic indicates that the returned duration_in_traffic should be longer than the actual travel time on most days, though occasional days with particularly bad traffic conditions may exceed this value.
    • optimistic indicates that the returned duration_in_traffic should be shorter than the actual travel time on most days, though occasional days with particularly good traffic conditions may be faster than this value.

    The default value of best_guess will give the most useful predictions for the vast majority of use cases. It is possible the best_guess travel time prediction may be shorter than optimistic , or alternatively, longer than pessimistic , due to the way the best_guess prediction model integrates live traffic information.

  • transit_mode

    Specifies one or more preferred modes of transit. This parameter may only be specified for transit directions. The parameter supports the following arguments:

    • bus indicates that the calculated route should prefer travel by bus.
    • subway indicates that the calculated route should prefer travel by subway.
    • train indicates that the calculated route should prefer travel by train.
    • tram indicates that the calculated route should prefer travel by tram and light rail.
    • rail indicates that the calculated route should prefer travel by train, tram, light rail, and subway. This is equivalent to transit_mode=train|tram|subway .
  • transit_routing_preference

    Specifies preferences for transit routes. Using this parameter, you can bias the options returned, rather than accepting the default best route chosen by the API. This parameter may only be specified for transit directions. The parameter supports the following arguments:

    • less_walking indicates that the calculated route should prefer limited amounts of walking.
    • fewer_transfers indicates that the calculated route should prefer a limited number of transfers.
  • units

    Specifies the unit system to use when displaying results.

    Note: this unit system setting only affects the text displayed within distance fields. The distance fields also contain values which are always expressed in meters.

উদাহরণ অনুরোধ করুন

এই উদাহরণটি গন্তব্য স্থানাঙ্ক নির্দিষ্ট করতে অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626
  &origins=40.6655101%2C-73.89188969999998
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=40.6655101%2C-73.89188969999998&destinations=40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626&key=YOUR_API_KEY'

এই উদাহরণটি গন্তব্য স্থানাঙ্ক নির্দিষ্ট করতে প্লাস কোড ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=San%20Francisco
  &origins=849VCWC8%2BR9
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=849VCWC8%2BR9&destinations=San%20Francisco&key=YOUR_API_KEY'

এই উদাহরণটি একটি এনকোডেড পলিলাইন ব্যবহার করে একই অনুরোধ দেখায়:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=enc%3A_kjwFjtsbMt%60EgnKcqLcaOzkGari%40naPxhVg%7CJjjb%40cqLcaOzkGari%40naPxhV%3A
  &origins=40.6655101%2C-73.89188969999998
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=40.6655101%2C-73.89188969999998&destinations=enc%3A_kjwFjtsbMt%60EgnKcqLcaOzkGari%40naPxhVg%7CJjjb%40cqLcaOzkGari%40naPxhV%3A&key=YOUR_API_KEY'

ট্রাফিক তথ্য

ট্র্যাফিক তথ্য ব্যবহার করা হয় যখন নিম্নলিখিতগুলি প্রযোজ্য হয় (এগুলি দূরত্ব ম্যাট্রিক্স প্রতিক্রিয়ায় duration_in_traffic ফিল্ড পাওয়ার জন্য প্রয়োজনীয় শর্তাবলী):

  • ভ্রমণ mode প্যারামিটারটি driving , বা নির্দিষ্ট করা নেই ( driving হল ডিফল্ট ভ্রমণ মোড)।
  • অনুরোধে একটি বৈধ departure_time প্যারামিটার অন্তর্ভুক্ত রয়েছে। departure_time বর্তমান সময়ে বা ভবিষ্যতে কিছু সময় সেট করা যেতে পারে। এটা অতীত হতে পারে না।

ঐচ্ছিকভাবে, আপনি আপনার অনুরোধে traffic_model প্যারামিটারটি অন্তর্ভুক্ত করতে পারেন যাতে ট্র্যাফিকের সময় গণনা করার সময় ব্যবহার করার জন্য অনুমানগুলি উল্লেখ করতে পারেন৷

নিম্নলিখিত URLটি বোস্টন, এমএ বা চার্লসটাউন, এমএ, এবং লেক্সিংটন, এমএ এবং কনকর্ড, এমএ-এর মধ্যে ড্রাইভিং দূরত্বের জন্য একটি দূরত্ব ম্যাট্রিক্স অনুরোধ শুরু করে৷ ডিসটেন্স ম্যাট্রিক্স প্রতিক্রিয়ায় duration_in_traffic ফিল্ড ফেরত দেওয়ার জন্য সমস্ত প্রয়োজনীয়তা পূরণ করে, একটি প্রস্থানের সময় অন্তর্ভুক্ত করে।

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?departure_time=now
  &destinations=Lexington%2CMA%7CConcord%2CMA
  &origins=Boston%2CMA%7CCharlestown%2CMA
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=Boston%2CMA%7CCharlestown%2CMA&destinations=Lexington%2CMA%7CConcord%2CMA&departure_time=now&key=YOUR_API_KEY'

JSON

{
  "destination_addresses": ["Lexington, MA, USA", "Concord, MA, USA"],
  "origin_addresses": ["Boston, MA, USA", "Charlestown, Boston, MA, USA"],
  "rows":
    [
      {
        "elements":
          [
            {
              "distance": { "text": "33.3 km", "value": 33253 },
              "duration": { "text": "27 mins", "value": 1620 },
              "duration_in_traffic": { "text": "34 mins", "value": 2019 },
              "status": "OK",
            },
            {
              "distance": { "text": "41.5 km", "value": 41491 },
              "duration": { "text": "33 mins", "value": 1981 },
              "duration_in_traffic": { "text": "39 mins", "value": 2342 },
              "status": "OK",
            },
          ],
      },
      {
        "elements":
          [
            {
              "distance": { "text": "31.1 km", "value": 31100 },
              "duration": { "text": "26 mins", "value": 1543 },
              "duration_in_traffic": { "text": "29 mins", "value": 1754 },
              "status": "OK",
            },
            {
              "distance": { "text": "39.3 km", "value": 39338 },
              "duration": { "text": "32 mins", "value": 1904 },
              "duration_in_traffic": { "text": "35 mins", "value": 2077 },
              "status": "OK",
            },
          ],
      },
    ],
  "status": "OK",
}

এক্সএমএল

<DistanceMatrixResponse>
 <status>OK</status>
 <origin_address>Boston, MA, USA</origin_address>
 <origin_address>Charlestown, Boston, MA, USA</origin_address>
 <destination_address>Lexington, MA, USA</destination_address>
 <destination_address>Concord, MA, USA</destination_address>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>1620</value>
    <text>27 mins</text>
   </duration>
   <distance>
    <value>33253</value>
    <text>33.3 km</text>
   </distance>
   <duration_in_traffic>
    <value>2018</value>
    <text>34 mins</text>
   </duration_in_traffic>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>1981</value>
    <text>33 mins</text>
   </duration>
   <distance>
    <value>41491</value>
    <text>41.5 km</text>
   </distance>
   <duration_in_traffic>
    <value>2342</value>
    <text>39 mins</text>
   </duration_in_traffic>
  </element>
 </row>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>1543</value>
    <text>26 mins</text>
   </duration>
   <distance>
    <value>31100</value>
    <text>31.1 km</text>
   </distance>
   <duration_in_traffic>
    <value>1759</value>
    <text>29 mins</text>
   </duration_in_traffic>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>1904</value>
    <text>32 mins</text>
   </duration>
   <distance>
    <value>39338</value>
    <text>39.3 km</text>
   </distance>
   <duration_in_traffic>
    <value>2077</value>
    <text>35 mins</text>
   </duration_in_traffic>
  </element>
 </row>
</DistanceMatrixResponse>

অবস্থান পরিবর্তনকারী

আপনি লোকেশন মডিফায়ার ব্যবহার করে নির্দেশ করতে পারেন যে কীভাবে ড্রাইভারদের একটি নির্দিষ্ট স্থানে যেতে হবে, রাস্তার কোন দিকটি ব্যবহার করতে হবে তা নির্দিষ্ট করার জন্য side_of_road মডিফায়ার ব্যবহার করে বা ভ্রমণের সঠিক দিক নির্দেশ করার জন্য একটি শিরোনাম উল্লেখ করে।

নির্দিষ্ট করুন যে গণনা করা রুটগুলি অবশ্যই রাস্তার একটি নির্দিষ্ট পাশ দিয়ে যেতে হবে

একটি অবস্থান নির্দিষ্ট করার সময়, আপনি অনুরোধ করতে পারেন যে গণনা করা রুটটি রাস্তার যে দিকেই হোক না কেন ওয়েপয়েন্টটি side_of_road: উপসর্গ ব্যবহার করে পক্ষপাতদুষ্ট। উদাহরণস্বরূপ, এই অনুরোধটি একটি দীর্ঘ পথের দূরত্ব ফিরিয়ে দেবে যাতে গাড়িটি রাস্তার পাশে শেষ হয় যেখানে ওয়েপয়েন্টটি পক্ষপাতদুষ্ট ছিল:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=side_of_road%3A37.7663444%2C-122.4412006
  &origins=37.7680296%2C-122.4375126
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=37.7680296%2C-122.4375126&destinations=side_of_road%3A37.7663444%2C-122.4412006&key=YOUR_API_KEY'

side_of_road: এনকোডেড পলিলাইন সহ, পলিলাইন বরাবর প্রতিটি অবস্থানে মডিফায়ার প্রয়োগ করা হয়। উদাহরণস্বরূপ, এই অনুরোধের দুটি গন্তব্য উভয়ই প্যারামিটার ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=side_of_road%3Aenc%3A%7BoqeF%60fejV%5BnC%3A
  &origins=San%20Francisco%20City%20hall
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=San%20Francisco%20City%20hall&destinations=side_of_road%3Aenc%3A%7BoqeF%60fejV%5BnC%3A&key=YOUR_API_KEY'

side_of_road: সংশোধক শুধুমাত্র এই সীমাবদ্ধতার সাথে ব্যবহার করা যেতে পারে:

নির্দিষ্ট করুন যে গণনা করা রুটের একটি নির্দিষ্ট শিরোনাম থাকা উচিত

একটি অবস্থান নির্দিষ্ট করার সময়, আপনি অনুরোধ করতে পারেন যে গণনা করা রুটটি একটি নির্দিষ্ট শিরোনামে অবস্থানের মধ্য দিয়ে যেতে পারে। এই শিরোনামটি উপসর্গ heading=X: দিয়ে নির্দিষ্ট করা হয়েছে, যেখানে X হল 0 (অন্তর্ভুক্ত) এবং 360 (একচেটিয়া) এর মধ্যে একটি পূর্ণসংখ্যা ডিগ্রী মান। 0 এর শিরোনাম উত্তর নির্দেশ করে, 90 পূর্ব নির্দেশ করে এবং তাই ঘড়ির কাঁটার দিকে চলতে থাকে। উদাহরণস্বরূপ, এই অনুরোধে গণনা করা রুটটি মূল থেকে পূর্ব দিকে যায়, তারপর একটি ইউ-টার্ন নেয়:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=37.773245%2C-122.469502
  &origins=heading%3D90%3A37.773279%2C-122.468780
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=heading%3D90%3A37.773279%2C-122.468780&destinations=37.773245%2C-122.469502&key=YOUR_API_KEY'

heading=X: সংশোধক শুধুমাত্র এই সীমাবদ্ধতার সাথে ব্যবহার করা যেতে পারে:

  • ভ্রমণ mode প্যারামিটারটি driving , bicycling , বা নির্দিষ্ট করা নেই ( driving হল ডিফল্ট ভ্রমণ মোড)।
  • side_of_road মডিফায়ার একই অবস্থানের জন্য নির্দিষ্ট করা নেই।
  • অবস্থান একটি অক্ষাংশ/দ্রাঘিমাংশ মান সঙ্গে নির্দিষ্ট করা হয়. আপনি ঠিকানা, স্থান আইডি, বা এনকোডেড পলিলাইন সহ heading ব্যবহার করতে পারবেন না।

দূরত্ব ম্যাট্রিক্স অনুরোধ এবং প্রতিক্রিয়া

একটি নমুনা HTTP অনুরোধ নীচে দেখানো হয়েছে, ভ্যাঙ্কুভার, BC, কানাডা এবং সিয়াটল, WA, USA থেকে সান ফ্রান্সিসকো, CA, USA এবং ভিক্টোরিয়া, BC, কানাডা থেকে দূরত্ব এবং সময়কালের জন্য অনুরোধ করে।

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=San%20Francisco%7CVictoria%20BC
  &language=fr-FR
  &mode=bicycling
  &origins=Vancouver%20BC%7CSeattle
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver%20BC%7CSeattle&destinations=San%20Francisco%7CVictoria%20BC&mode=bicycling&language=fr-FR&key=YOUR_API_KEY'

এই অনুরোধটি চারটি উপাদান ফিরিয়ে দেবে - দুটি উত্স গুণ দুটি গন্তব্য:

ভ্যাঙ্কুভার থেকে সান ফ্রান্সিসকো ভ্যাঙ্কুভার থেকে ভিক্টোরিয়া
সিয়াটল থেকে সান ফ্রান্সিসকো সিয়াটল থেকে ভিক্টোরিয়া

ফলাফলগুলি সারিগুলিতে প্রত্যাবর্তন করা হয়, প্রতিটি সারিতে প্রতিটি গন্তব্যের সাথে একটি মূল যুক্ত থাকে।

JSON

{
  "destination_addresses":
    ["San Francisco, Californie, États-Unis", "Victoria, BC, Canada"],
  "origin_addresses":
    ["Vancouver, BC, Canada", "Seattle, Washington, États-Unis"],
  "rows":
    [
      {
        "elements":
          [
            {
              "distance": { "text": "1712 km", "value": 1711765 },
              "duration": { "text": "3 jours 16 heures", "value": 318119 },
              "status": "OK",
            },
            {
              "distance": { "text": "140 km", "value": 139695 },
              "duration": { "text": "6 heures 49 minutes", "value": 24567 },
              "status": "OK",
            },
          ],
      },
      {
        "elements":
          [
            {
              "distance": { "text": "1452 km", "value": 1451704 },
              "duration": { "text": "3 jours 2 heures", "value": 266680 },
              "status": "OK",
            },
            {
              "distance": { "text": "146 km", "value": 146500 },
              "duration": { "text": "2 heures 53 minutes", "value": 10374 },
              "status": "OK",
            },
          ],
      },
    ],
  "status": "OK",
}

এক্সএমএল

<DistanceMatrixResponse>
 <status>OK</status>
 <origin_address>Vancouver, BC, Canada</origin_address>
 <origin_address>Seattle, Washington, États-Unis</origin_address>
 <destination_address>San Francisco, Californie, États-Unis</destination_address>
 <destination_address>Victoria, BC, Canada</destination_address>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>318119</value>
    <text>3 jours 16 heures</text>
   </duration>
   <distance>
    <value>1711765</value>
    <text>1712 km</text>
   </distance>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>24567</value>
    <text>6 heures 49 minutes</text>
   </duration>
   <distance>
    <value>139695</value>
    <text>140 km</text>
   </distance>
  </element>
 </row>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>266680</value>
    <text>3 jours 2 heures</text>
   </duration>
   <distance>
    <value>1451704</value>
    <text>1452 km</text>
   </distance>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>10374</value>
    <text>2 heures 53 minutes</text>
   </duration>
   <distance>
    <value>146500</value>
    <text>146 km</text>
   </distance>
  </element>
 </row>
</DistanceMatrixResponse>

DistanceMatrixResponse

FieldRequiredTypeDescription
required Array<string>

An array of addresses as returned by the API from your original request. As with origin_addresses , these are localized if appropriate. This content is meant to be read as-is. Do not programatically parse the formatted addresses.

required Array<string>

An array of addresses as returned by the API from your original request. These are formatted by the geocoder and localized according to the language parameter passed with the request. This content is meant to be read as-is. Do not programatically parse the formatted addresses.

required Array< DistanceMatrixRow >

An array of elements, which in turn each contain a status , duration , and distance element.

See DistanceMatrixRow for more information.

required DistanceMatrixStatus

Contains the status of the request, and may contain debugging information to help you track down why the request failed.

See DistanceMatrixStatus for more information.

optionalstring

A string containing the human-readable text of any errors encountered while the request was being processed.

DistanceMatrixStatus

Status codes returned by service.

  • OK indicates the response contains a valid result.
  • INVALID_REQUEST indicates that the provided request was invalid.
  • MAX_ELEMENTS_EXCEEDED indicates that the product of origins and destinations exceeds the per-query limit.
  • MAX_DIMENSIONS_EXCEEDED indicates that the number of origins or destinations exceeds the per-query limit.
  • OVER_DAILY_LIMIT indicates any of the following:
    • The API key is missing or invalid.
    • Billing has not been enabled on your account.
    • A self-imposed usage cap has been exceeded.
    • The provided method of payment is no longer valid (for example, a credit card has expired).
  • OVER_QUERY_LIMIT indicates the service has received too many requests from your application within the allowed time period.
  • REQUEST_DENIED indicates that the service denied use of the Distance Matrix service by your application.
  • UNKNOWN_ERROR indicates a Distance Matrix request could not be processed due to a server error. The request may succeed if you try again.

DistanceMatrixRow

FieldRequiredTypeDescription
required Array< DistanceMatrixElement >

When the Distance Matrix API returns results, it places them within a JSON rows array. Even if no results are returned (such as when the origins and/or destinations don't exist), it still returns an empty array.

Rows are ordered according to the values in the origin parameter of the request. Each row corresponds to an origin, and each element within that row corresponds to a pairing of the origin with a destination value.

Each row array contains one or more element entries, which in turn contain the information about a single origin-destination pairing.

See DistanceMatrixElement for more information.

DistanceMatrixElement

FieldRequiredTypeDescription
required DistanceMatrixElementStatus

A status for the element.

See DistanceMatrixElementStatus for more information.

optional TextValueObject

The total distance of this route, expressed in meters (value) and as text. The textual value uses the unit system specified with the unit parameter of the original request, or the origin's region.

See TextValueObject for more information.

optional TextValueObject

The length of time it takes to travel this route, expressed in seconds (the value field) and as text. The textual representation is localized according to the query's language parameter.

See TextValueObject for more information.

optional TextValueObject

The length of time it takes to travel this route, based on current and historical traffic conditions. See the traffic_model request parameter for the options you can use to request that the returned value is optimistic, pessimistic, or a best-guess estimate. The duration is expressed in seconds (the value field) and as text. The textual representation is localized according to the query's language parameter. The duration in traffic is returned only if all of the following are true:

  • The request includes a departure_time parameter.
  • Traffic conditions are available for the requested route.
  • The mode parameter is set to driving.

See TextValueObject for more information.

optional Fare

If present, contains the total fare (that is, the total ticket costs) on this route. This property is only returned for transit requests and only for transit providers where fare information is available.

See Fare for more information.

Fare

The total fare for the route.

{
  "currency" : "USD",
  "value" : 6,
  "text" : "$6.00"
}
FieldRequiredTypeDescription
required string

An ISO 4217 currency code indicating the currency that the amount is expressed in.

required string

The total fare amount, formatted in the requested language.

required number

The total fare amount, in the currency specified.

DistanceMatrixElementStatus

  • OK indicates the response contains a valid result.
  • NOT_FOUND indicates that the origin and/or destination of this pairing could not be geocoded.
  • ZERO_RESULTS indicates no route could be found between the origin and destination.
  • MAX_ROUTE_LENGTH_EXCEEDED indicates the requested route is too long and cannot be processed.

TextValueObject

An object containing a numeric value and its formatted text representation.

FieldRequiredTypeDescription
required string

String value.

required number

Numeric value.

,

একটি দূরত্ব ম্যাট্রিক্স API অনুরোধ নিম্নলিখিত ফর্ম নেয়:

https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters

যেখানে outputFormat নিম্নলিখিত মানগুলির মধ্যে একটি হতে পারে:

  • json (প্রস্তাবিত), জাভাস্ক্রিপ্ট অবজেক্ট নোটেশনে আউটপুট নির্দেশ করে (JSON); বা
  • xml , XML হিসাবে আউটপুট নির্দেশ করে।

কিছু প্যারামিটার প্রয়োজন যখন অন্যরা ঐচ্ছিক। ইউআরএল-এ স্ট্যান্ডার্ড হিসাবে, অ্যাম্পারস্যান্ড ( & ) অক্ষর ব্যবহার করে সমস্ত প্যারামিটার আলাদা করা হয়। সমস্ত সংরক্ষিত অক্ষর (উদাহরণস্বরূপ প্লাস চিহ্ন "+") অবশ্যই URL-এনকোডেড হতে হবে। পরামিতিগুলির তালিকা এবং তাদের সম্ভাব্য মানগুলি নীচে গণনা করা হয়েছে।

Required parameters

  • destinations

    One or more locations to use as the finishing point for calculating travel distance and time. The options for the destinations parameter are the same as for the origins parameter.

  • origins

    The starting point for calculating travel distance and time. You can supply one or more locations separated by the pipe character (|), in the form of a place ID, an address, or latitude/longitude coordinates:

    • Place ID : If you supply a place ID, you must prefix it with place_id: .
    • Address : If you pass an address, the service geocodes the string and converts it to a latitude/longitude coordinate to calculate distance. This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center.
      Note: using place IDs is preferred over using addresses or latitude/longitude coordinates. Using coordinates will always result in the point being snapped to the road nearest to those coordinates - which may not be an access point to the property, or even a road that will quickly or safely lead to the destination. Using the address will provide the distance to the center of the building, as opposed to an entrance to the building.
    • Coordinates : If you pass latitude/longitude coordinates, they they will snap to the nearest road. Passing a place ID is preferred. If you do pass coordinates, ensure that no space exists between the latitude and longitude values.
    • Plus codes must be formatted as a global code or a compound code. Format plus codes as shown here (plus signs are url-escaped to %2B and spaces are url-escaped to %20):
      • global code is a 4 character area code and 6 character or longer local code ( 849VCWC8+R9 is encoded to 849VCWC8%2BR9 ).
      • compound code is a 6 character or longer local code with an explicit location ( CWC8+R9 Mountain View, CA, USA is encoded to CWC8%2BR9%20Mountain%20View%20CA%20USA ).
    • Encoded Polyline Alternatively, you can supply an encoded set of coordinates using the Encoded Polyline Algorithm . This is particularly useful if you have a large number of origin points, because the URL is significantly shorter when using an encoded polyline.
      • Encoded polylines must be prefixed with enc: and followed by a colon : . For example: origins=enc:gfo}EtohhU:
      • You can also include multiple encoded polylines, separated by the pipe character | . For example:
        origins=enc:wc~oAwquwMdlTxiKtqLyiK:|enc:c~vnAamswMvlTor@tjGi}L:|enc:udymA{~bxM:
        

Optional parameters

  • 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.

  • avoid

    Distances may be calculated that adhere to certain restrictions. Restrictions are indicated by use of the avoid parameter, and an argument to that parameter indicating the restriction to avoid. The following restrictions are supported:

    • tolls indicates that the calculated route should avoid toll roads/bridges.
    • highways indicates that the calculated route should avoid highways.
    • ferries indicates that the calculated route should avoid ferries.
    • indoor indicates that the calculated route should avoid indoor steps for walking and transit directions.

    It's possible to request a route that avoids any combination of tolls, highways and ferries by passing both restrictions to the avoid parameter. For example avoid=tolls|highways|ferries .

    Note: The addition of restrictions does not preclude routes that include the restricted feature; it biases the result to more favorable routes.
  • departure_time

    Specifies the desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC. If a departure_time later than 9999-12-31T23:59:59.999999999Z is specified, the API will fall back the departure_time to 9999-12-31T23:59:59.999999999Z. Alternatively, you can specify a value of now, which sets the departure time to the current time (correct to the nearest second). The departure time may be specified in two cases:

    • For requests where the travel mode is transit: You can optionally specify one of departure_time or arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time).
    • For requests where the travel mode is driving: You can specify the departure_time to receive a route and trip duration (response field: duration_in_traffic) that take traffic conditions into account. The departure_time must be set to the current time or some time in the future. It cannot be in the past.
    Note: If departure time is not specified, choice of route and duration are based on road network and average time-independent traffic conditions. Results for a given request may vary over time due to changes in the road network, updated average traffic conditions, and the distributed nature of the service. Results may also vary between nearly-equivalent routes at any time or frequency.
    Note: Distance Matrix requests specifying `departure_time` when `mode=driving` are limited to a maximum of 100 elements per request. The number of origins times the number of destinations defines the number of elements.
  • language

    The language in which to return results.

    • See the list of supported languages . Google often updates the supported languages, so this list may not be exhaustive.
    • If language is not supplied, the API attempts to use the preferred language as specified in the Accept-Language header.
    • The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
    • If a name is not available in the preferred language, the API uses the closest match.
    • The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.
  • mode

    For the calculation of distances and directions, you may specify the transportation mode to use. By default, DRIVING mode is used. By default, directions are calculated as driving directions. The following travel modes are supported:

    • driving (default) indicates standard driving directions or distance using the road network.
    • walking requests walking directions or distance via pedestrian paths & sidewalks (where available).
    • bicycling requests bicycling directions or distance via bicycle paths & preferred streets (where available).
    • transit requests directions or distance via public transit routes (where available). Transit trips are available for up to 7 days in the past or 100 days in the future. If you set the mode to transit, you can optionally specify either a departure_time or an arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). You can also optionally include a transit_mode and/or a transit_routing_preference .
    Note: Both walking and bicycling directions may sometimes not include clear pedestrian or bicycling paths, so these directions will return warnings in the returned result which you must display to the user.
  • region

    The region code, specified as a ccTLD ("top-level domain") two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom's ccTLD is "uk" (.co.uk) while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland").

  • traffic_model

    Specifies the assumptions to use when calculating time in traffic. This setting affects the value returned in the duration_in_traffic field in the response, which contains the predicted time in traffic based on historical averages. The traffic_model parameter may only be specified for driving directions where the request includes a departure_time . The available values for this parameter are:

    • best_guess (default) indicates that the returned duration_in_traffic should be the best estimate of travel time given what is known about both historical traffic conditions and live traffic. Live traffic becomes more important the closer the departure_time is to now.
    • pessimistic indicates that the returned duration_in_traffic should be longer than the actual travel time on most days, though occasional days with particularly bad traffic conditions may exceed this value.
    • optimistic indicates that the returned duration_in_traffic should be shorter than the actual travel time on most days, though occasional days with particularly good traffic conditions may be faster than this value.

    The default value of best_guess will give the most useful predictions for the vast majority of use cases. It is possible the best_guess travel time prediction may be shorter than optimistic , or alternatively, longer than pessimistic , due to the way the best_guess prediction model integrates live traffic information.

  • transit_mode

    Specifies one or more preferred modes of transit. This parameter may only be specified for transit directions. The parameter supports the following arguments:

    • bus indicates that the calculated route should prefer travel by bus.
    • subway indicates that the calculated route should prefer travel by subway.
    • train indicates that the calculated route should prefer travel by train.
    • tram indicates that the calculated route should prefer travel by tram and light rail.
    • rail indicates that the calculated route should prefer travel by train, tram, light rail, and subway. This is equivalent to transit_mode=train|tram|subway .
  • transit_routing_preference

    Specifies preferences for transit routes. Using this parameter, you can bias the options returned, rather than accepting the default best route chosen by the API. This parameter may only be specified for transit directions. The parameter supports the following arguments:

    • less_walking indicates that the calculated route should prefer limited amounts of walking.
    • fewer_transfers indicates that the calculated route should prefer a limited number of transfers.
  • units

    Specifies the unit system to use when displaying results.

    Note: this unit system setting only affects the text displayed within distance fields. The distance fields also contain values which are always expressed in meters.

উদাহরণ অনুরোধ করুন

এই উদাহরণটি গন্তব্য স্থানাঙ্ক নির্দিষ্ট করতে অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626
  &origins=40.6655101%2C-73.89188969999998
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=40.6655101%2C-73.89188969999998&destinations=40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626&key=YOUR_API_KEY'

এই উদাহরণটি গন্তব্য স্থানাঙ্ক নির্দিষ্ট করতে প্লাস কোড ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=San%20Francisco
  &origins=849VCWC8%2BR9
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=849VCWC8%2BR9&destinations=San%20Francisco&key=YOUR_API_KEY'

এই উদাহরণটি একটি এনকোডেড পলিলাইন ব্যবহার করে একই অনুরোধ দেখায়:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=enc%3A_kjwFjtsbMt%60EgnKcqLcaOzkGari%40naPxhVg%7CJjjb%40cqLcaOzkGari%40naPxhV%3A
  &origins=40.6655101%2C-73.89188969999998
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=40.6655101%2C-73.89188969999998&destinations=enc%3A_kjwFjtsbMt%60EgnKcqLcaOzkGari%40naPxhVg%7CJjjb%40cqLcaOzkGari%40naPxhV%3A&key=YOUR_API_KEY'

ট্রাফিক তথ্য

ট্র্যাফিক তথ্য ব্যবহার করা হয় যখন নিম্নলিখিতগুলি প্রযোজ্য হয় (এগুলি দূরত্ব ম্যাট্রিক্স প্রতিক্রিয়ায় duration_in_traffic ফিল্ড পাওয়ার জন্য প্রয়োজনীয় শর্তাবলী):

  • ভ্রমণ mode প্যারামিটারটি driving , বা নির্দিষ্ট করা নেই ( driving হল ডিফল্ট ভ্রমণ মোড)।
  • অনুরোধে একটি বৈধ departure_time প্যারামিটার অন্তর্ভুক্ত রয়েছে। departure_time বর্তমান সময়ে বা ভবিষ্যতে কিছু সময় সেট করা যেতে পারে। এটা অতীত হতে পারে না।

ঐচ্ছিকভাবে, আপনি আপনার অনুরোধে traffic_model প্যারামিটারটি অন্তর্ভুক্ত করতে পারেন যাতে ট্র্যাফিকের সময় গণনা করার সময় ব্যবহার করার জন্য অনুমানগুলি উল্লেখ করতে পারেন৷

নিম্নলিখিত URLটি বোস্টন, এমএ বা চার্লসটাউন, এমএ, এবং লেক্সিংটন, এমএ এবং কনকর্ড, এমএ-এর মধ্যে ড্রাইভিং দূরত্বের জন্য একটি দূরত্ব ম্যাট্রিক্স অনুরোধ শুরু করে৷ ডিসট্যান্স ম্যাট্রিক্স প্রতিক্রিয়ায় duration_in_traffic ফিল্ড ফেরত দেওয়ার জন্য সমস্ত প্রয়োজনীয়তা পূরণ করে, একটি প্রস্থানের সময় অন্তর্ভুক্ত করে।

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?departure_time=now
  &destinations=Lexington%2CMA%7CConcord%2CMA
  &origins=Boston%2CMA%7CCharlestown%2CMA
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=Boston%2CMA%7CCharlestown%2CMA&destinations=Lexington%2CMA%7CConcord%2CMA&departure_time=now&key=YOUR_API_KEY'

JSON

{
  "destination_addresses": ["Lexington, MA, USA", "Concord, MA, USA"],
  "origin_addresses": ["Boston, MA, USA", "Charlestown, Boston, MA, USA"],
  "rows":
    [
      {
        "elements":
          [
            {
              "distance": { "text": "33.3 km", "value": 33253 },
              "duration": { "text": "27 mins", "value": 1620 },
              "duration_in_traffic": { "text": "34 mins", "value": 2019 },
              "status": "OK",
            },
            {
              "distance": { "text": "41.5 km", "value": 41491 },
              "duration": { "text": "33 mins", "value": 1981 },
              "duration_in_traffic": { "text": "39 mins", "value": 2342 },
              "status": "OK",
            },
          ],
      },
      {
        "elements":
          [
            {
              "distance": { "text": "31.1 km", "value": 31100 },
              "duration": { "text": "26 mins", "value": 1543 },
              "duration_in_traffic": { "text": "29 mins", "value": 1754 },
              "status": "OK",
            },
            {
              "distance": { "text": "39.3 km", "value": 39338 },
              "duration": { "text": "32 mins", "value": 1904 },
              "duration_in_traffic": { "text": "35 mins", "value": 2077 },
              "status": "OK",
            },
          ],
      },
    ],
  "status": "OK",
}

এক্সএমএল

<DistanceMatrixResponse>
 <status>OK</status>
 <origin_address>Boston, MA, USA</origin_address>
 <origin_address>Charlestown, Boston, MA, USA</origin_address>
 <destination_address>Lexington, MA, USA</destination_address>
 <destination_address>Concord, MA, USA</destination_address>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>1620</value>
    <text>27 mins</text>
   </duration>
   <distance>
    <value>33253</value>
    <text>33.3 km</text>
   </distance>
   <duration_in_traffic>
    <value>2018</value>
    <text>34 mins</text>
   </duration_in_traffic>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>1981</value>
    <text>33 mins</text>
   </duration>
   <distance>
    <value>41491</value>
    <text>41.5 km</text>
   </distance>
   <duration_in_traffic>
    <value>2342</value>
    <text>39 mins</text>
   </duration_in_traffic>
  </element>
 </row>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>1543</value>
    <text>26 mins</text>
   </duration>
   <distance>
    <value>31100</value>
    <text>31.1 km</text>
   </distance>
   <duration_in_traffic>
    <value>1759</value>
    <text>29 mins</text>
   </duration_in_traffic>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>1904</value>
    <text>32 mins</text>
   </duration>
   <distance>
    <value>39338</value>
    <text>39.3 km</text>
   </distance>
   <duration_in_traffic>
    <value>2077</value>
    <text>35 mins</text>
   </duration_in_traffic>
  </element>
 </row>
</DistanceMatrixResponse>

অবস্থান পরিবর্তনকারী

আপনি লোকেশন মডিফায়ার ব্যবহার করে নির্দেশ করতে পারেন যে কীভাবে ড্রাইভারদের একটি নির্দিষ্ট স্থানে যেতে হবে, রাস্তার কোন দিকটি ব্যবহার করতে হবে তা নির্দিষ্ট করার জন্য side_of_road মডিফায়ার ব্যবহার করে বা ভ্রমণের সঠিক দিক নির্দেশ করার জন্য একটি শিরোনাম উল্লেখ করে।

নির্দিষ্ট করুন যে গণনা করা রুটগুলি অবশ্যই রাস্তার একটি নির্দিষ্ট পাশ দিয়ে যেতে হবে

একটি অবস্থান নির্দিষ্ট করার সময়, আপনি অনুরোধ করতে পারেন যে গণনা করা রুটটি রাস্তার যে দিকেই হোক না কেন ওয়েপয়েন্টটি side_of_road: উপসর্গ ব্যবহার করে পক্ষপাতদুষ্ট। উদাহরণস্বরূপ, এই অনুরোধটি একটি দীর্ঘ পথের দূরত্ব ফিরিয়ে দেবে যাতে গাড়িটি রাস্তার পাশে শেষ হয় যেখানে ওয়েপয়েন্টটি পক্ষপাতদুষ্ট ছিল:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=side_of_road%3A37.7663444%2C-122.4412006
  &origins=37.7680296%2C-122.4375126
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=37.7680296%2C-122.4375126&destinations=side_of_road%3A37.7663444%2C-122.4412006&key=YOUR_API_KEY'

side_of_road: এনকোডেড পলিলাইন সহ, পলিলাইন বরাবর প্রতিটি অবস্থানে মডিফায়ার প্রয়োগ করা হয়। উদাহরণস্বরূপ, এই অনুরোধের দুটি গন্তব্য উভয়ই প্যারামিটার ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=side_of_road%3Aenc%3A%7BoqeF%60fejV%5BnC%3A
  &origins=San%20Francisco%20City%20hall
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=San%20Francisco%20City%20hall&destinations=side_of_road%3Aenc%3A%7BoqeF%60fejV%5BnC%3A&key=YOUR_API_KEY'

side_of_road: সংশোধক শুধুমাত্র এই সীমাবদ্ধতার সাথে ব্যবহার করা যেতে পারে:

নির্দিষ্ট করুন যে গণনা করা রুটের একটি নির্দিষ্ট শিরোনাম থাকা উচিত

একটি অবস্থান নির্দিষ্ট করার সময়, আপনি অনুরোধ করতে পারেন যে গণনা করা রুটটি একটি নির্দিষ্ট শিরোনামে অবস্থানের মধ্য দিয়ে যেতে পারে। এই শিরোনামটি উপসর্গ heading=X: দিয়ে নির্দিষ্ট করা হয়েছে, যেখানে X হল 0 (অন্তর্ভুক্ত) এবং 360 (একচেটিয়া) এর মধ্যে একটি পূর্ণসংখ্যা ডিগ্রী মান। 0 এর শিরোনাম উত্তর নির্দেশ করে, 90 পূর্ব নির্দেশ করে এবং তাই ঘড়ির কাঁটার দিকে চলতে থাকে। উদাহরণস্বরূপ, এই অনুরোধে গণনা করা রুটটি মূল থেকে পূর্ব দিকে যায়, তারপর একটি ইউ-টার্ন নেয়:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=37.773245%2C-122.469502
  &origins=heading%3D90%3A37.773279%2C-122.468780
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=heading%3D90%3A37.773279%2C-122.468780&destinations=37.773245%2C-122.469502&key=YOUR_API_KEY'

heading=X: সংশোধক শুধুমাত্র এই সীমাবদ্ধতার সাথে ব্যবহার করা যেতে পারে:

  • ভ্রমণ mode প্যারামিটারটি driving , bicycling , বা নির্দিষ্ট করা নেই ( driving হল ডিফল্ট ভ্রমণ মোড)।
  • side_of_road মডিফায়ার একই অবস্থানের জন্য নির্দিষ্ট করা নেই।
  • অবস্থান একটি অক্ষাংশ/দ্রাঘিমাংশ মান সঙ্গে নির্দিষ্ট করা হয়. আপনি ঠিকানা, স্থান আইডি, বা এনকোডেড পলিলাইন সহ heading ব্যবহার করতে পারবেন না।

দূরত্ব ম্যাট্রিক্স অনুরোধ এবং প্রতিক্রিয়া

একটি নমুনা HTTP অনুরোধ নীচে দেখানো হয়েছে, ভ্যাঙ্কুভার, BC, কানাডা এবং সিয়াটল, WA, USA থেকে সান ফ্রান্সিসকো, CA, USA এবং ভিক্টোরিয়া, BC, কানাডা থেকে দূরত্ব এবং সময়কালের জন্য অনুরোধ করে।

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=San%20Francisco%7CVictoria%20BC
  &language=fr-FR
  &mode=bicycling
  &origins=Vancouver%20BC%7CSeattle
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver%20BC%7CSeattle&destinations=San%20Francisco%7CVictoria%20BC&mode=bicycling&language=fr-FR&key=YOUR_API_KEY'

এই অনুরোধটি চারটি উপাদান ফিরিয়ে দেবে - দুটি উত্স গুণ দুটি গন্তব্য:

ভ্যাঙ্কুভার থেকে সান ফ্রান্সিসকো ভ্যাঙ্কুভার থেকে ভিক্টোরিয়া
সিয়াটল থেকে সান ফ্রান্সিসকো সিয়াটল থেকে ভিক্টোরিয়া

ফলাফলগুলি সারিগুলিতে প্রত্যাবর্তন করা হয়, প্রতিটি সারিতে প্রতিটি গন্তব্যের সাথে একটি মূল যুক্ত থাকে।

JSON

{
  "destination_addresses":
    ["San Francisco, Californie, États-Unis", "Victoria, BC, Canada"],
  "origin_addresses":
    ["Vancouver, BC, Canada", "Seattle, Washington, États-Unis"],
  "rows":
    [
      {
        "elements":
          [
            {
              "distance": { "text": "1712 km", "value": 1711765 },
              "duration": { "text": "3 jours 16 heures", "value": 318119 },
              "status": "OK",
            },
            {
              "distance": { "text": "140 km", "value": 139695 },
              "duration": { "text": "6 heures 49 minutes", "value": 24567 },
              "status": "OK",
            },
          ],
      },
      {
        "elements":
          [
            {
              "distance": { "text": "1452 km", "value": 1451704 },
              "duration": { "text": "3 jours 2 heures", "value": 266680 },
              "status": "OK",
            },
            {
              "distance": { "text": "146 km", "value": 146500 },
              "duration": { "text": "2 heures 53 minutes", "value": 10374 },
              "status": "OK",
            },
          ],
      },
    ],
  "status": "OK",
}

এক্সএমএল

<DistanceMatrixResponse>
 <status>OK</status>
 <origin_address>Vancouver, BC, Canada</origin_address>
 <origin_address>Seattle, Washington, États-Unis</origin_address>
 <destination_address>San Francisco, Californie, États-Unis</destination_address>
 <destination_address>Victoria, BC, Canada</destination_address>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>318119</value>
    <text>3 jours 16 heures</text>
   </duration>
   <distance>
    <value>1711765</value>
    <text>1712 km</text>
   </distance>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>24567</value>
    <text>6 heures 49 minutes</text>
   </duration>
   <distance>
    <value>139695</value>
    <text>140 km</text>
   </distance>
  </element>
 </row>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>266680</value>
    <text>3 jours 2 heures</text>
   </duration>
   <distance>
    <value>1451704</value>
    <text>1452 km</text>
   </distance>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>10374</value>
    <text>2 heures 53 minutes</text>
   </duration>
   <distance>
    <value>146500</value>
    <text>146 km</text>
   </distance>
  </element>
 </row>
</DistanceMatrixResponse>

DistanceMatrixResponse

FieldRequiredTypeDescription
required Array<string>

An array of addresses as returned by the API from your original request. As with origin_addresses , these are localized if appropriate. This content is meant to be read as-is. Do not programatically parse the formatted addresses.

required Array<string>

An array of addresses as returned by the API from your original request. These are formatted by the geocoder and localized according to the language parameter passed with the request. This content is meant to be read as-is. Do not programatically parse the formatted addresses.

required Array< DistanceMatrixRow >

An array of elements, which in turn each contain a status , duration , and distance element.

See DistanceMatrixRow for more information.

required DistanceMatrixStatus

Contains the status of the request, and may contain debugging information to help you track down why the request failed.

See DistanceMatrixStatus for more information.

optionalstring

A string containing the human-readable text of any errors encountered while the request was being processed.

DistanceMatrixStatus

Status codes returned by service.

  • OK indicates the response contains a valid result.
  • INVALID_REQUEST indicates that the provided request was invalid.
  • MAX_ELEMENTS_EXCEEDED indicates that the product of origins and destinations exceeds the per-query limit.
  • MAX_DIMENSIONS_EXCEEDED indicates that the number of origins or destinations exceeds the per-query limit.
  • OVER_DAILY_LIMIT indicates any of the following:
    • The API key is missing or invalid.
    • Billing has not been enabled on your account.
    • A self-imposed usage cap has been exceeded.
    • The provided method of payment is no longer valid (for example, a credit card has expired).
  • OVER_QUERY_LIMIT indicates the service has received too many requests from your application within the allowed time period.
  • REQUEST_DENIED indicates that the service denied use of the Distance Matrix service by your application.
  • UNKNOWN_ERROR indicates a Distance Matrix request could not be processed due to a server error. The request may succeed if you try again.

DistanceMatrixRow

FieldRequiredTypeDescription
required Array< DistanceMatrixElement >

When the Distance Matrix API returns results, it places them within a JSON rows array. Even if no results are returned (such as when the origins and/or destinations don't exist), it still returns an empty array.

Rows are ordered according to the values in the origin parameter of the request. Each row corresponds to an origin, and each element within that row corresponds to a pairing of the origin with a destination value.

Each row array contains one or more element entries, which in turn contain the information about a single origin-destination pairing.

See DistanceMatrixElement for more information.

DistanceMatrixElement

FieldRequiredTypeDescription
required DistanceMatrixElementStatus

A status for the element.

See DistanceMatrixElementStatus for more information.

optional TextValueObject

The total distance of this route, expressed in meters (value) and as text. The textual value uses the unit system specified with the unit parameter of the original request, or the origin's region.

See TextValueObject for more information.

optional TextValueObject

The length of time it takes to travel this route, expressed in seconds (the value field) and as text. The textual representation is localized according to the query's language parameter.

See TextValueObject for more information.

optional TextValueObject

The length of time it takes to travel this route, based on current and historical traffic conditions. See the traffic_model request parameter for the options you can use to request that the returned value is optimistic, pessimistic, or a best-guess estimate. The duration is expressed in seconds (the value field) and as text. The textual representation is localized according to the query's language parameter. The duration in traffic is returned only if all of the following are true:

  • The request includes a departure_time parameter.
  • Traffic conditions are available for the requested route.
  • The mode parameter is set to driving.

See TextValueObject for more information.

optional Fare

If present, contains the total fare (that is, the total ticket costs) on this route. This property is only returned for transit requests and only for transit providers where fare information is available.

See Fare for more information.

Fare

The total fare for the route.

{
  "currency" : "USD",
  "value" : 6,
  "text" : "$6.00"
}
FieldRequiredTypeDescription
required string

An ISO 4217 currency code indicating the currency that the amount is expressed in.

required string

The total fare amount, formatted in the requested language.

required number

The total fare amount, in the currency specified.

DistanceMatrixElementStatus

  • OK indicates the response contains a valid result.
  • NOT_FOUND indicates that the origin and/or destination of this pairing could not be geocoded.
  • ZERO_RESULTS indicates no route could be found between the origin and destination.
  • MAX_ROUTE_LENGTH_EXCEEDED indicates the requested route is too long and cannot be processed.

TextValueObject

An object containing a numeric value and its formatted text representation.

FieldRequiredTypeDescription
required string

String value.

required number

Numeric value.

,

একটি দূরত্ব ম্যাট্রিক্স API অনুরোধ নিম্নলিখিত ফর্ম নেয়:

https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters

যেখানে outputFormat নিম্নলিখিত মানগুলির মধ্যে একটি হতে পারে:

  • json (প্রস্তাবিত), জাভাস্ক্রিপ্ট অবজেক্ট নোটেশনে আউটপুট নির্দেশ করে (JSON); বা
  • xml , XML হিসাবে আউটপুট নির্দেশ করে।

কিছু প্যারামিটার প্রয়োজন যখন অন্যরা ঐচ্ছিক। ইউআরএল-এ স্ট্যান্ডার্ড হিসাবে, অ্যাম্পারস্যান্ড ( & ) অক্ষর ব্যবহার করে সমস্ত প্যারামিটার আলাদা করা হয়। সমস্ত সংরক্ষিত অক্ষর (উদাহরণস্বরূপ প্লাস চিহ্ন "+") অবশ্যই URL-এনকোডেড হতে হবে। পরামিতিগুলির তালিকা এবং তাদের সম্ভাব্য মানগুলি নীচে গণনা করা হয়েছে।

Required parameters

  • destinations

    One or more locations to use as the finishing point for calculating travel distance and time. The options for the destinations parameter are the same as for the origins parameter.

  • origins

    The starting point for calculating travel distance and time. You can supply one or more locations separated by the pipe character (|), in the form of a place ID, an address, or latitude/longitude coordinates:

    • Place ID : If you supply a place ID, you must prefix it with place_id: .
    • Address : If you pass an address, the service geocodes the string and converts it to a latitude/longitude coordinate to calculate distance. This coordinate may be different from that returned by the Geocoding API, for example a building entrance rather than its center.
      Note: using place IDs is preferred over using addresses or latitude/longitude coordinates. Using coordinates will always result in the point being snapped to the road nearest to those coordinates - which may not be an access point to the property, or even a road that will quickly or safely lead to the destination. Using the address will provide the distance to the center of the building, as opposed to an entrance to the building.
    • Coordinates : If you pass latitude/longitude coordinates, they they will snap to the nearest road. Passing a place ID is preferred. If you do pass coordinates, ensure that no space exists between the latitude and longitude values.
    • Plus codes must be formatted as a global code or a compound code. Format plus codes as shown here (plus signs are url-escaped to %2B and spaces are url-escaped to %20):
      • global code is a 4 character area code and 6 character or longer local code ( 849VCWC8+R9 is encoded to 849VCWC8%2BR9 ).
      • compound code is a 6 character or longer local code with an explicit location ( CWC8+R9 Mountain View, CA, USA is encoded to CWC8%2BR9%20Mountain%20View%20CA%20USA ).
    • Encoded Polyline Alternatively, you can supply an encoded set of coordinates using the Encoded Polyline Algorithm . This is particularly useful if you have a large number of origin points, because the URL is significantly shorter when using an encoded polyline.
      • Encoded polylines must be prefixed with enc: and followed by a colon : . For example: origins=enc:gfo}EtohhU:
      • You can also include multiple encoded polylines, separated by the pipe character | . For example:
        origins=enc:wc~oAwquwMdlTxiKtqLyiK:|enc:c~vnAamswMvlTor@tjGi}L:|enc:udymA{~bxM:
        

Optional parameters

  • 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.

  • avoid

    Distances may be calculated that adhere to certain restrictions. Restrictions are indicated by use of the avoid parameter, and an argument to that parameter indicating the restriction to avoid. The following restrictions are supported:

    • tolls indicates that the calculated route should avoid toll roads/bridges.
    • highways indicates that the calculated route should avoid highways.
    • ferries indicates that the calculated route should avoid ferries.
    • indoor indicates that the calculated route should avoid indoor steps for walking and transit directions.

    It's possible to request a route that avoids any combination of tolls, highways and ferries by passing both restrictions to the avoid parameter. For example avoid=tolls|highways|ferries .

    Note: The addition of restrictions does not preclude routes that include the restricted feature; it biases the result to more favorable routes.
  • departure_time

    Specifies the desired time of departure. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC. If a departure_time later than 9999-12-31T23:59:59.999999999Z is specified, the API will fall back the departure_time to 9999-12-31T23:59:59.999999999Z. Alternatively, you can specify a value of now, which sets the departure time to the current time (correct to the nearest second). The departure time may be specified in two cases:

    • For requests where the travel mode is transit: You can optionally specify one of departure_time or arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time).
    • For requests where the travel mode is driving: You can specify the departure_time to receive a route and trip duration (response field: duration_in_traffic) that take traffic conditions into account. The departure_time must be set to the current time or some time in the future. It cannot be in the past.
    Note: If departure time is not specified, choice of route and duration are based on road network and average time-independent traffic conditions. Results for a given request may vary over time due to changes in the road network, updated average traffic conditions, and the distributed nature of the service. Results may also vary between nearly-equivalent routes at any time or frequency.
    Note: Distance Matrix requests specifying `departure_time` when `mode=driving` are limited to a maximum of 100 elements per request. The number of origins times the number of destinations defines the number of elements.
  • language

    The language in which to return results.

    • See the list of supported languages . Google often updates the supported languages, so this list may not be exhaustive.
    • If language is not supplied, the API attempts to use the preferred language as specified in the Accept-Language header.
    • The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
    • If a name is not available in the preferred language, the API uses the closest match.
    • The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.
  • mode

    For the calculation of distances and directions, you may specify the transportation mode to use. By default, DRIVING mode is used. By default, directions are calculated as driving directions. The following travel modes are supported:

    • driving (default) indicates standard driving directions or distance using the road network.
    • walking requests walking directions or distance via pedestrian paths & sidewalks (where available).
    • bicycling requests bicycling directions or distance via bicycle paths & preferred streets (where available).
    • transit requests directions or distance via public transit routes (where available). Transit trips are available for up to 7 days in the past or 100 days in the future. If you set the mode to transit, you can optionally specify either a departure_time or an arrival_time . If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). You can also optionally include a transit_mode and/or a transit_routing_preference .
    Note: Both walking and bicycling directions may sometimes not include clear pedestrian or bicycling paths, so these directions will return warnings in the returned result which you must display to the user.
  • region

    The region code, specified as a ccTLD ("top-level domain") two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, the United Kingdom's ccTLD is "uk" (.co.uk) while its ISO 3166-1 code is "gb" (technically for the entity of "The United Kingdom of Great Britain and Northern Ireland").

  • traffic_model

    Specifies the assumptions to use when calculating time in traffic. This setting affects the value returned in the duration_in_traffic field in the response, which contains the predicted time in traffic based on historical averages. The traffic_model parameter may only be specified for driving directions where the request includes a departure_time . The available values for this parameter are:

    • best_guess (default) indicates that the returned duration_in_traffic should be the best estimate of travel time given what is known about both historical traffic conditions and live traffic. Live traffic becomes more important the closer the departure_time is to now.
    • pessimistic indicates that the returned duration_in_traffic should be longer than the actual travel time on most days, though occasional days with particularly bad traffic conditions may exceed this value.
    • optimistic indicates that the returned duration_in_traffic should be shorter than the actual travel time on most days, though occasional days with particularly good traffic conditions may be faster than this value.

    The default value of best_guess will give the most useful predictions for the vast majority of use cases. It is possible the best_guess travel time prediction may be shorter than optimistic , or alternatively, longer than pessimistic , due to the way the best_guess prediction model integrates live traffic information.

  • transit_mode

    Specifies one or more preferred modes of transit. This parameter may only be specified for transit directions. The parameter supports the following arguments:

    • bus indicates that the calculated route should prefer travel by bus.
    • subway indicates that the calculated route should prefer travel by subway.
    • train indicates that the calculated route should prefer travel by train.
    • tram indicates that the calculated route should prefer travel by tram and light rail.
    • rail indicates that the calculated route should prefer travel by train, tram, light rail, and subway. This is equivalent to transit_mode=train|tram|subway .
  • transit_routing_preference

    Specifies preferences for transit routes. Using this parameter, you can bias the options returned, rather than accepting the default best route chosen by the API. This parameter may only be specified for transit directions. The parameter supports the following arguments:

    • less_walking indicates that the calculated route should prefer limited amounts of walking.
    • fewer_transfers indicates that the calculated route should prefer a limited number of transfers.
  • units

    Specifies the unit system to use when displaying results.

    Note: this unit system setting only affects the text displayed within distance fields. The distance fields also contain values which are always expressed in meters.

উদাহরণ অনুরোধ করুন

এই উদাহরণটি গন্তব্য স্থানাঙ্ক নির্দিষ্ট করতে অক্ষাংশ/দ্রাঘিমাংশ স্থানাঙ্ক ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626
  &origins=40.6655101%2C-73.89188969999998
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=40.6655101%2C-73.89188969999998&destinations=40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626&key=YOUR_API_KEY'

এই উদাহরণটি গন্তব্য স্থানাঙ্ক নির্দিষ্ট করতে প্লাস কোড ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=San%20Francisco
  &origins=849VCWC8%2BR9
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=849VCWC8%2BR9&destinations=San%20Francisco&key=YOUR_API_KEY'

এই উদাহরণটি একটি এনকোডেড পলিলাইন ব্যবহার করে একই অনুরোধ দেখায়:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=enc%3A_kjwFjtsbMt%60EgnKcqLcaOzkGari%40naPxhVg%7CJjjb%40cqLcaOzkGari%40naPxhV%3A
  &origins=40.6655101%2C-73.89188969999998
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=40.6655101%2C-73.89188969999998&destinations=enc%3A_kjwFjtsbMt%60EgnKcqLcaOzkGari%40naPxhVg%7CJjjb%40cqLcaOzkGari%40naPxhV%3A&key=YOUR_API_KEY'

ট্রাফিক তথ্য

ট্র্যাফিক তথ্য ব্যবহার করা হয় যখন নিম্নলিখিতগুলি প্রযোজ্য হয় (এগুলি দূরত্ব ম্যাট্রিক্স প্রতিক্রিয়ায় duration_in_traffic ফিল্ড পাওয়ার জন্য প্রয়োজনীয় শর্তাবলী):

  • ভ্রমণ mode প্যারামিটারটি driving , বা নির্দিষ্ট করা নেই ( driving হল ডিফল্ট ভ্রমণ মোড)।
  • অনুরোধে একটি বৈধ departure_time প্যারামিটার অন্তর্ভুক্ত রয়েছে। departure_time বর্তমান সময়ে বা ভবিষ্যতে কিছু সময় সেট করা যেতে পারে। এটা অতীত হতে পারে না।

ঐচ্ছিকভাবে, আপনি আপনার অনুরোধে traffic_model প্যারামিটারটি অন্তর্ভুক্ত করতে পারেন যাতে ট্র্যাফিকের সময় গণনা করার সময় ব্যবহার করার জন্য অনুমানগুলি উল্লেখ করতে পারেন৷

নিম্নলিখিত URLটি বোস্টন, এমএ বা চার্লসটাউন, এমএ, এবং লেক্সিংটন, এমএ এবং কনকর্ড, এমএ-এর মধ্যে ড্রাইভিং দূরত্বের জন্য একটি দূরত্ব ম্যাট্রিক্স অনুরোধ শুরু করে৷ ডিসটেন্স ম্যাট্রিক্স প্রতিক্রিয়ায় duration_in_traffic ফিল্ড ফেরত দেওয়ার জন্য সমস্ত প্রয়োজনীয়তা পূরণ করে, একটি প্রস্থানের সময় অন্তর্ভুক্ত করে।

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?departure_time=now
  &destinations=Lexington%2CMA%7CConcord%2CMA
  &origins=Boston%2CMA%7CCharlestown%2CMA
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=Boston%2CMA%7CCharlestown%2CMA&destinations=Lexington%2CMA%7CConcord%2CMA&departure_time=now&key=YOUR_API_KEY'

JSON

{
  "destination_addresses": ["Lexington, MA, USA", "Concord, MA, USA"],
  "origin_addresses": ["Boston, MA, USA", "Charlestown, Boston, MA, USA"],
  "rows":
    [
      {
        "elements":
          [
            {
              "distance": { "text": "33.3 km", "value": 33253 },
              "duration": { "text": "27 mins", "value": 1620 },
              "duration_in_traffic": { "text": "34 mins", "value": 2019 },
              "status": "OK",
            },
            {
              "distance": { "text": "41.5 km", "value": 41491 },
              "duration": { "text": "33 mins", "value": 1981 },
              "duration_in_traffic": { "text": "39 mins", "value": 2342 },
              "status": "OK",
            },
          ],
      },
      {
        "elements":
          [
            {
              "distance": { "text": "31.1 km", "value": 31100 },
              "duration": { "text": "26 mins", "value": 1543 },
              "duration_in_traffic": { "text": "29 mins", "value": 1754 },
              "status": "OK",
            },
            {
              "distance": { "text": "39.3 km", "value": 39338 },
              "duration": { "text": "32 mins", "value": 1904 },
              "duration_in_traffic": { "text": "35 mins", "value": 2077 },
              "status": "OK",
            },
          ],
      },
    ],
  "status": "OK",
}

এক্সএমএল

<DistanceMatrixResponse>
 <status>OK</status>
 <origin_address>Boston, MA, USA</origin_address>
 <origin_address>Charlestown, Boston, MA, USA</origin_address>
 <destination_address>Lexington, MA, USA</destination_address>
 <destination_address>Concord, MA, USA</destination_address>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>1620</value>
    <text>27 mins</text>
   </duration>
   <distance>
    <value>33253</value>
    <text>33.3 km</text>
   </distance>
   <duration_in_traffic>
    <value>2018</value>
    <text>34 mins</text>
   </duration_in_traffic>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>1981</value>
    <text>33 mins</text>
   </duration>
   <distance>
    <value>41491</value>
    <text>41.5 km</text>
   </distance>
   <duration_in_traffic>
    <value>2342</value>
    <text>39 mins</text>
   </duration_in_traffic>
  </element>
 </row>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>1543</value>
    <text>26 mins</text>
   </duration>
   <distance>
    <value>31100</value>
    <text>31.1 km</text>
   </distance>
   <duration_in_traffic>
    <value>1759</value>
    <text>29 mins</text>
   </duration_in_traffic>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>1904</value>
    <text>32 mins</text>
   </duration>
   <distance>
    <value>39338</value>
    <text>39.3 km</text>
   </distance>
   <duration_in_traffic>
    <value>2077</value>
    <text>35 mins</text>
   </duration_in_traffic>
  </element>
 </row>
</DistanceMatrixResponse>

অবস্থান পরিবর্তনকারী

আপনি লোকেশন মডিফায়ার ব্যবহার করে নির্দেশ করতে পারেন যে কীভাবে ড্রাইভারদের একটি নির্দিষ্ট স্থানে যেতে হবে, রাস্তার কোন দিকটি ব্যবহার করতে হবে তা নির্দিষ্ট করার জন্য side_of_road মডিফায়ার ব্যবহার করে বা ভ্রমণের সঠিক দিক নির্দেশ করার জন্য একটি শিরোনাম উল্লেখ করে।

নির্দিষ্ট করুন যে গণনা করা রুটগুলি অবশ্যই রাস্তার একটি নির্দিষ্ট পাশ দিয়ে যেতে হবে

একটি অবস্থান নির্দিষ্ট করার সময়, আপনি অনুরোধ করতে পারেন যে গণনা করা রুটটি রাস্তার যে দিকেই হোক না কেন ওয়েপয়েন্টটি side_of_road: উপসর্গ ব্যবহার করে পক্ষপাতদুষ্ট। উদাহরণস্বরূপ, এই অনুরোধটি একটি দীর্ঘ পথের দূরত্ব ফিরিয়ে দেবে যাতে গাড়িটি রাস্তার পাশে শেষ হয় যেখানে ওয়েপয়েন্টটি পক্ষপাতদুষ্ট ছিল:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=side_of_road%3A37.7663444%2C-122.4412006
  &origins=37.7680296%2C-122.4375126
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=37.7680296%2C-122.4375126&destinations=side_of_road%3A37.7663444%2C-122.4412006&key=YOUR_API_KEY'

side_of_road: এনকোডেড পলিলাইন সহ, পলিলাইন বরাবর প্রতিটি অবস্থানে মডিফায়ার প্রয়োগ করা হয়। উদাহরণস্বরূপ, এই অনুরোধের দুটি গন্তব্য উভয়ই প্যারামিটার ব্যবহার করে:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=side_of_road%3Aenc%3A%7BoqeF%60fejV%5BnC%3A
  &origins=San%20Francisco%20City%20hall
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=San%20Francisco%20City%20hall&destinations=side_of_road%3Aenc%3A%7BoqeF%60fejV%5BnC%3A&key=YOUR_API_KEY'

side_of_road: সংশোধক শুধুমাত্র এই সীমাবদ্ধতার সাথে ব্যবহার করা যেতে পারে:

নির্দিষ্ট করুন যে গণনা করা রুটের একটি নির্দিষ্ট শিরোনাম থাকা উচিত

একটি অবস্থান নির্দিষ্ট করার সময়, আপনি অনুরোধ করতে পারেন যে গণনা করা রুটটি একটি নির্দিষ্ট শিরোনামে অবস্থানের মধ্য দিয়ে যেতে পারে। এই শিরোনামটি উপসর্গ heading=X: দিয়ে নির্দিষ্ট করা হয়েছে, যেখানে X হল 0 (অন্তর্ভুক্ত) এবং 360 (একচেটিয়া) এর মধ্যে একটি পূর্ণসংখ্যা ডিগ্রী মান। 0 এর শিরোনাম উত্তর নির্দেশ করে, 90 পূর্ব নির্দেশ করে এবং তাই ঘড়ির কাঁটার দিকে চলতে থাকে। উদাহরণস্বরূপ, এই অনুরোধে গণনা করা রুটটি মূল থেকে পূর্ব দিকে যায়, তারপর একটি ইউ-টার্ন নেয়:

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=37.773245%2C-122.469502
  &origins=heading%3D90%3A37.773279%2C-122.468780
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=heading%3D90%3A37.773279%2C-122.468780&destinations=37.773245%2C-122.469502&key=YOUR_API_KEY'

heading=X: সংশোধক শুধুমাত্র এই সীমাবদ্ধতার সাথে ব্যবহার করা যেতে পারে:

  • ভ্রমণ mode প্যারামিটারটি driving , bicycling , বা নির্দিষ্ট করা নেই ( driving হল ডিফল্ট ভ্রমণ মোড)।
  • side_of_road মডিফায়ার একই অবস্থানের জন্য নির্দিষ্ট করা নেই।
  • অবস্থান একটি অক্ষাংশ/দ্রাঘিমাংশ মান সঙ্গে নির্দিষ্ট করা হয়. আপনি ঠিকানা, স্থান আইডি, বা এনকোডেড পলিলাইন সহ heading ব্যবহার করতে পারবেন না।

দূরত্ব ম্যাট্রিক্স অনুরোধ এবং প্রতিক্রিয়া

একটি নমুনা HTTP অনুরোধ নীচে দেখানো হয়েছে, ভ্যাঙ্কুভার, BC, কানাডা এবং সিয়াটল, WA, USA থেকে সান ফ্রান্সিসকো, CA, USA এবং ভিক্টোরিয়া, BC, কানাডা থেকে দূরত্ব এবং সময়কালের জন্য অনুরোধ করে।

URL

https://maps.googleapis.com/maps/api/distancematrix/json
  ?destinations=San%20Francisco%7CVictoria%20BC
  &language=fr-FR
  &mode=bicycling
  &origins=Vancouver%20BC%7CSeattle
  &key=YOUR_API_KEY

cURL

curl -L -X GET 'https://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver%20BC%7CSeattle&destinations=San%20Francisco%7CVictoria%20BC&mode=bicycling&language=fr-FR&key=YOUR_API_KEY'

এই অনুরোধটি চারটি উপাদান ফিরিয়ে দেবে - দুটি উত্স গুণ দুটি গন্তব্য:

ভ্যাঙ্কুভার থেকে সান ফ্রান্সিসকো ভ্যাঙ্কুভার থেকে ভিক্টোরিয়া
সিয়াটল থেকে সান ফ্রান্সিসকো সিয়াটল থেকে ভিক্টোরিয়া

ফলাফলগুলি সারিগুলিতে প্রত্যাবর্তন করা হয়, প্রতিটি সারিতে প্রতিটি গন্তব্যের সাথে একটি মূল যুক্ত থাকে।

JSON

{
  "destination_addresses":
    ["San Francisco, Californie, États-Unis", "Victoria, BC, Canada"],
  "origin_addresses":
    ["Vancouver, BC, Canada", "Seattle, Washington, États-Unis"],
  "rows":
    [
      {
        "elements":
          [
            {
              "distance": { "text": "1712 km", "value": 1711765 },
              "duration": { "text": "3 jours 16 heures", "value": 318119 },
              "status": "OK",
            },
            {
              "distance": { "text": "140 km", "value": 139695 },
              "duration": { "text": "6 heures 49 minutes", "value": 24567 },
              "status": "OK",
            },
          ],
      },
      {
        "elements":
          [
            {
              "distance": { "text": "1452 km", "value": 1451704 },
              "duration": { "text": "3 jours 2 heures", "value": 266680 },
              "status": "OK",
            },
            {
              "distance": { "text": "146 km", "value": 146500 },
              "duration": { "text": "2 heures 53 minutes", "value": 10374 },
              "status": "OK",
            },
          ],
      },
    ],
  "status": "OK",
}

এক্সএমএল

<DistanceMatrixResponse>
 <status>OK</status>
 <origin_address>Vancouver, BC, Canada</origin_address>
 <origin_address>Seattle, Washington, États-Unis</origin_address>
 <destination_address>San Francisco, Californie, États-Unis</destination_address>
 <destination_address>Victoria, BC, Canada</destination_address>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>318119</value>
    <text>3 jours 16 heures</text>
   </duration>
   <distance>
    <value>1711765</value>
    <text>1712 km</text>
   </distance>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>24567</value>
    <text>6 heures 49 minutes</text>
   </duration>
   <distance>
    <value>139695</value>
    <text>140 km</text>
   </distance>
  </element>
 </row>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>266680</value>
    <text>3 jours 2 heures</text>
   </duration>
   <distance>
    <value>1451704</value>
    <text>1452 km</text>
   </distance>
  </element>
  <element>
   <status>OK</status>
   <duration>
    <value>10374</value>
    <text>2 heures 53 minutes</text>
   </duration>
   <distance>
    <value>146500</value>
    <text>146 km</text>
   </distance>
  </element>
 </row>
</DistanceMatrixResponse>

DistanceMatrixResponse

FieldRequiredTypeDescription
required Array<string>

An array of addresses as returned by the API from your original request. As with origin_addresses , these are localized if appropriate. This content is meant to be read as-is. Do not programatically parse the formatted addresses.

required Array<string>

An array of addresses as returned by the API from your original request. These are formatted by the geocoder and localized according to the language parameter passed with the request. This content is meant to be read as-is. Do not programatically parse the formatted addresses.

required Array< DistanceMatrixRow >

An array of elements, which in turn each contain a status , duration , and distance element.

See DistanceMatrixRow for more information.

required DistanceMatrixStatus

Contains the status of the request, and may contain debugging information to help you track down why the request failed.

See DistanceMatrixStatus for more information.

optionalstring

A string containing the human-readable text of any errors encountered while the request was being processed.

DistanceMatrixStatus

Status codes returned by service.

  • OK indicates the response contains a valid result.
  • INVALID_REQUEST indicates that the provided request was invalid.
  • MAX_ELEMENTS_EXCEEDED indicates that the product of origins and destinations exceeds the per-query limit.
  • MAX_DIMENSIONS_EXCEEDED indicates that the number of origins or destinations exceeds the per-query limit.
  • OVER_DAILY_LIMIT indicates any of the following:
    • The API key is missing or invalid.
    • Billing has not been enabled on your account.
    • A self-imposed usage cap has been exceeded.
    • The provided method of payment is no longer valid (for example, a credit card has expired).
  • OVER_QUERY_LIMIT indicates the service has received too many requests from your application within the allowed time period.
  • REQUEST_DENIED indicates that the service denied use of the Distance Matrix service by your application.
  • UNKNOWN_ERROR indicates a Distance Matrix request could not be processed due to a server error. The request may succeed if you try again.

DistanceMatrixRow

FieldRequiredTypeDescription
required Array< DistanceMatrixElement >

When the Distance Matrix API returns results, it places them within a JSON rows array. Even if no results are returned (such as when the origins and/or destinations don't exist), it still returns an empty array.

Rows are ordered according to the values in the origin parameter of the request. Each row corresponds to an origin, and each element within that row corresponds to a pairing of the origin with a destination value.

Each row array contains one or more element entries, which in turn contain the information about a single origin-destination pairing.

See DistanceMatrixElement for more information.

DistanceMatrixElement

FieldRequiredTypeDescription
required DistanceMatrixElementStatus

A status for the element.

See DistanceMatrixElementStatus for more information.

optional TextValueObject

The total distance of this route, expressed in meters (value) and as text. The textual value uses the unit system specified with the unit parameter of the original request, or the origin's region.

See TextValueObject for more information.

optional TextValueObject

The length of time it takes to travel this route, expressed in seconds (the value field) and as text. The textual representation is localized according to the query's language parameter.

See TextValueObject for more information.

optional TextValueObject

The length of time it takes to travel this route, based on current and historical traffic conditions. See the traffic_model request parameter for the options you can use to request that the returned value is optimistic, pessimistic, or a best-guess estimate. The duration is expressed in seconds (the value field) and as text. The textual representation is localized according to the query's language parameter. The duration in traffic is returned only if all of the following are true:

  • The request includes a departure_time parameter.
  • Traffic conditions are available for the requested route.
  • The mode parameter is set to driving.

See TextValueObject for more information.

optional Fare

If present, contains the total fare (that is, the total ticket costs) on this route. This property is only returned for transit requests and only for transit providers where fare information is available.

See Fare for more information.

Fare

The total fare for the route.

{
  "currency" : "USD",
  "value" : 6,
  "text" : "$6.00"
}
FieldRequiredTypeDescription
required string

An ISO 4217 currency code indicating the currency that the amount is expressed in.

required string

The total fare amount, formatted in the requested language.

required number

The total fare amount, in the currency specified.

DistanceMatrixElementStatus

  • OK indicates the response contains a valid result.
  • NOT_FOUND indicates that the origin and/or destination of this pairing could not be geocoded.
  • ZERO_RESULTS indicates no route could be found between the origin and destination.
  • MAX_ROUTE_LENGTH_EXCEEDED indicates the requested route is too long and cannot be processed.

TextValueObject

An object containing a numeric value and its formatted text representation.

FieldRequiredTypeDescription
required string

String value.

required number

Numeric value.