JSFiddle - React, Tailwind, and code Playground

HTML

<!DOCTYPE html>
<html>
<head>
  <title>Map Route with Custom Markers</title>
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg"></script>
  <style>
    #map {
      height: 400px;
      width: 100%;
    }
  </style>
</head>
<body>
  <div id="map"></div>

  <script>
    $(document).ready(function() {
      var map;
      var directionsService;
      var directionsRenderer;

      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: 40.7128, lng: -74.0060}, // New York
          zoom: 10
        });

        directionsService = new google.maps.DirectionsService();
        directionsRenderer = new google.maps.DirectionsRenderer({
          map: map
        });
      }

      function calculateAndDisplayRoute(start, end, waypoints) {
        directionsService.route({
          origin: start,
          destination: end,
          waypoints: waypoints,
          optimizeWaypoints: true,
          travelMode: 'DRIVING'
        }, function(response, status) {
          if (status === 'OK') {
            directionsRenderer.setDirections(response);

            var route = response.routes[0];
            for (var i = 0; i < route.legs.length; i++) {
              addCustomMarkers(route.legs[i].start_location, 'Start');
              addCustomMarkers(route.legs[i].end_location, 'End');
            }

            if (waypoints) {
               waypoints.forEach(function(waypoint) {
                  addCustomMarkers(waypoint.location, 'Waypoint');
               });
            }
          } else {
            window.alert('Directions request failed due to ' + status);
          }
        });
      }
      
      function addCustomMarkers(location, label) {
          new google.maps.Marker({
            position: location,
            map: map,
            label: label,
            icon: { //...