Google Maps api with KML layer

I’ve got this code by following an example from Google maps api and I create my own kml files, but the stringline appear with no markers for start and end. How would I go about adding markers to these two points ?

I’ve been looking at finding the first and last entry in the array of locations, but are there a different way ?

<script>
      var map;
      var src = 'https://www.domain.com/files/<?php echo $data[0][kmlFile]; ?>';

      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: new google.maps.LatLng(-19.257753, 146.823688),
          zoom: 3,
          mapTypeId: 'terrain'
        });

        var kmlLayer = new google.maps.KmlLayer(src, {
          suppressInfoWindows: true,
          preserveViewport: false,
          map: map
        });
        kmlLayer.addListener('click', function(event) {
          var content = event.featureData.infoWindowHtml;
          var testimonial = document.getElementById('capture');
          testimonial.innerHTML = content;
        });
      }
    </script>
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=mykey&callback=initMap">
    </script>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.