How to "get directions" using Google Maps in Ionic app?

Hi, I am trying to “get directions” on a Google Map in my ionic app.

On my Ionic app, I am adding some markers to a Google Map.

I want users to be able to get directions from their current location to one of the markers, in the same way you can get directions to a point with the Google Maps app.

Below is how I’m displaying a Google Map in my ionic app currently:

this.getGoogleMaps().then((googleMaps) => {
    const mapEl = this.mapElementRef.nativeElement;
    const map = new googleMaps.Map(mapEl, {
    center: this.coordinates,
    zoom: 10,
    });
});

private getGoogleMaps() {
    const win = window as any;
    const googleModule = win.google;

    if (googleModule && googleModule.maps) {
        return Promise.resolve(googleModule.maps);
    }

return new Promise((resolve, reject) => {
    const script = document.createElement("script");
    script.src = "https://maps.googleapis.com/maps/api/js?key=myKey";
    script.async = true;
    script.defer = true;
    document.body.appendChild(script);
    script.onload = () => {
        const loadedGoogleModule = win.google;
    
        if (loadedGoogleModule && loadedGoogleModule.maps) {
            resolve(loadedGoogleModule.maps);
        } else {
        reject("Google Maps SDK not available.");
        }
    };
    });
}

Can someone please tell me how I can add this “get directions” functionality to my Ionic app?

You might want to check the Google Maps license agreement. It’s been several years since I have done so, and something may have changed in the meantime, but what you ask at least used to be explicitly prohibited in there.