function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Display route map on goolgemaps from current location

I have displayed all the contacts and Leads on google maps from the cuurent location with 10km distance
here i have displayed an infowindow including button named Getdirection for each marker(Contacts and Leads),
here i need to display the route map from current location to particular selected marker

Thanks & Regards
Gaurav KheterpalGaurav Kheterpal
You need to use the Directions Service to show the route map. For example
navigator.geolocation.getCurrentPosition(function (position) {

    var latitude = position.coords.latitude;
    var longitude = position.coords.longitude;
    var coords = new google.maps.LatLng(latitude, longitude);
    var request = {
        origin: coords,
        destination: "{!Account.BillingStreet},{!Account.BillingCity},{!Account.BillingState}",
        travelMode: google.maps.DirectionsTravelMode.DRIVING
If my answer helps resolve your query, please mark it as the 'Best Answer' to benefit others and improve the overall quality of Discussion Forums.