Driving distance support

Created on 16 March 2025, 17 days ago

Problem/Motivation

I have two nodes one labeled "origin" and one labeled "Destinations", both have geo locations fields being populated by geocoder. I have a view that pulls both node types and address as well as the geofield.
In the View, I have exposed filters for both Origin and Destination.

What I need is to have a field that displays the driving distance between the two points based on the exposed filters.
Let's say origin 1 has five destinations, the view would list all five entries with the end field having the miles/km value. I have been able to do this before using the Proximity Module but that only calculates the direct distance using the cosign method. I need the driving distance which can be considerably different.

Is this possible using the Leaflet module with Google Routes API?

💬 Support request
Status

Active

Version

10.2

Component

Miscellaneous

Created by

🇵🇹Portugal joaomachado

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @joaomachado
  • 🇮🇹Italy itamair

    hi @joaomachado ...
    thanks for posting this.

    Your description is a bit confusional.
    You mention different content types labelled as Origins, or Destinations, then you also mention the Proximity Module, that is not clear what it is ... and also you ask if you could mix the Leaflet module functionalities with the Google Routes API,

    Well. it's hard to be exhaustive here, without spending a lot of time (that personally I don't have now ...).
    But I would point you into some helpful directions, possibly.

    If you implement a Leaflet View Map then you should eventually be able to add to it the:
    Leaflet Routing Machine (https://github.com/perliedman/leaflet-routing-machine) and build your own interactive solution on top of it ...
    How?
    Well, you should be able to master Leaflet Js library and its plugins and know how to extend the Drupal Leaflet Map View.
    Probably this Drupal Leaflet issue should provide you with proper hints: https://www.drupal.org/project/leaflet/issues/3047091 📌 Leaflet Map & Markers external interaction, on events - LIVE DEMO Needs review

    Google Routes API? may be also ... but in that case you will send the user out of the Drupal website for processing the navigation operations.

    May be also the Geofield Directions module could be inspirational to you: https://www.drupal.org/project/geofield_directions
    Also see this dedicated brief video: https://www.youtube.com/watch?v=7HxuVQ8WlNA
    As far as I understood it simply implements a Geofield Formatter that Links out to a Google Map that presets that Target Direction from ... well, I guess where you are, or whatever you choose as Google Map starting point.

    But may be you could grab its code, and eventually generate a Computed Field that automatically generates a Google Map link with preset both origin and destination taken from a pair of Origin and Destination geofield entities ...

    Kind of all that / those ...

Production build 0.71.5 2024