title: Having a problem adding a call to a Perl CGI script from a Mouse Click Event Listener
body: <p>I have a Google Maps javascript with a Mouse Click Event handler defined. On a mouse click, a popup window appears with the lat long position of the click. I am attempting to add calculating the distance and bearing the current and last mouse position clicks. My Perl CGI script is working fine, and can receive a lat and long as paramters in the URL address call. My Perl CGI script calculates the distance and bearing between the 2 mouse clicks and puts the data in a small single line file. My javascript logic for reading the small file works fine by itself. I am having a problem adding this logic to my event listener.  Here is my current attempt that is not working:</p>
  <pre><code>// Configure the click listener.
  map.addListener('click', function(mapsMouseEvent) {
   
    ret = &quot;https://kjm.positiondatabase.com/cgi-bin/Distance?lat2=event.latLng.lat&amp;long2=event.latLng.lng&quot;;
   
    const fs = require('fs');
    fs.readFile('/tmp/DataOUT.txt', (err, data) =&gt; {
      if (err) throw err;
    })
   
  // Create a new InfoWindow.
    infoWindow = new google.maps.InfoWindow({position: mapsMouseEvent.latLng});
    infoWindow.setContent(data.toString());
    infoWindow.open(map);
   
  });
  </code></pre>
  <p>I am assuming the lat and long position of the mouse click is event.latLng.lat and event.latLng.lng.
  My Perl CGI script is not being called. If I remove the call to my Perl script, there are still problems. If anyone has any suggestions for how I can correct my script, all suggestions and help are appreciated.
  Thanks, Jim</p>