0

We have built a rental based website using Magento 2.3. When we create a rental product via admin, we can put the pickup address for that product. Now, we want to show a approximate distance from the end user to the pickup address in product page.

We came to know there is service in google called Distance matrix service. How to use this service in Magento to show the above said thing?

Your help is greatly appreciated.

0

To configure Google Maps Distance Matrix Service:

You do not need a Google account to get started. The process includes Google account and project creation if needed. This option requires a billing account and payment method added to your Google account to complete configurations and use the algorithm.

Step 1: Create the Google API Key

The key is from the Google Maps Platform and should have Geocoding API and Distance Matrix API enabled. For details, see Configuring Distance Priority Algorithm.

  • Visit Google Maps Platform and click Get Started.
  • To enable the platform, select Maps, Routes, and Places and click Continue. enter image description here

    Google Maps Platform for your Key

  • Sign in with a Google account or create a new account.

  • Set up a project:

    • Select a project or enter a new project name.
    • Select Yes to accept the terms.
    • Click Next.
  • Enter a billing account, or create one. You can skip and add a billing account later. The account is required to use this service.

  • Click Console to open and configure your Google Cloud Platform options.

    • Open your project.
    • Expand the menu and click APIs & Services > Library. enter image description here

      Google API Services

  • Search for Geocoding API and Distance Matrix API. Select and enable each service.

  • Expand the menu and click APIs & Services > Credentials. Copy the Google API Key.

enter image description here

Google API Key Copy

Step 2: Configure the Google MAP Provider

  • On the Admin sidebar, click Stores. Then under Settings, choose Configuration.
  • In the panel on the left under Catalog, choose Inventory.
  • Expand the Distance Provider for Distance Based SSA section, and set Providerto Google MAP. enter image description here

    Distance Providers for Distance Based SSA

  • Expand the Google Distance Provider section, and configure the settings:

  • Enter the Google API Key, copied from your Google Account.
  • For Computation mode, select a configuration.

When using this algorithm for shipping, if routes and data does not return for the selected Computation mode (driving, bicycling, or walking) for a shipment, the SSA defaults to using the Source Priority. We recommend also setting the priority for sources per stock.

Option

  • Driving Default setting, requests standard driving directions using the road network
  • Walking Requests walking directions using pedestrian paths and sidewalks (where available)
  • Bicycling Requests bicycling directions using bicycle paths and preferred streets (where available). The Distance Matrix Service is currently only available in the US and some Canadian cities.

For Value, select a value type:

Option

  • Distance Default setting, returns the distance between points in metrics (kilometers and meters) or imperial (miles and feet)
  • Time to Destination Returns the time required to travel from the source locations to the shipping address in hours and minutes

enter image description here Google Distance Provider

When complete, click Save Config .

Reference: https://docs.magento.com/m2/ce/user_guide/catalog/inventory-configure-distance-priority.html

I hope this will help

1
  • Thanks for this. How can I show the distance from source to destination in frontend? – Siva Jul 31 '19 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.