title: How to calculate an area based on the set of Latitude and longitude values using javascript?
body: <p>How to calculate an area based on the set of Latitude and longitude values using javascript ?</p>
  
  <p>I have a set of latitude and longitude values that I have extracted from my own database. they look like that:</p>
  
  <pre><code> // Define the LatLng coordinates for the polygon's path.
   var fizuliCoords = [
  {lng:47.1648244,lat:39.6834661},
  {lng:47.1653823,lat:39.6906634},
  ........there are 400-1200 lines...I only list 2
  ];
  var bakuCoords = [
  {lng:47.1648244,lat:39.6834661},
  {lng:47.1653823,lat:39.6906634},
  ........there are 400-1200 lines...I only list 2
  ];
  </code></pre>
  
  <p>there are 69 different administrative regions</p>
  
  <p>My project is:</p>
  
  <ol>
  <li>list the polygon</li>
  <li>automatically calculate the area based on the set of lat/long values
  I am a total newbe - so please be patient with me :)
  I can extract the area in sqkm from a program called Expert GPS with no problems for known shpaes, but I need an automated script.
  thanks
  .....
  my apologies, first timer :)</li>
  </ol>
  
  <p>ok,</p>
  
  <pre><code>     &lt;!DOCTYPE html&gt;
        &lt;html&gt;
     &lt;head&gt;
      &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no"&gt;
       &lt;meta charset="utf-8"&gt;
       &lt;title&gt;ttttt&lt;/title&gt;
       &lt;style&gt;
          html, body {
          height: 100%;
          margin: 0;
          padding: 0;
        }
   /*   #map is the div that places map on the html page*/
        #map {
          height: 100%;
         }
  /*    end of #map */      
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="map"&gt;&lt;/div&gt;
       &lt;script&gt;
    // This example creates a simple polygon representing the shusha Region.
    //the initMapfunction places the map on the page
     function initMap() {
      var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 8,
      center: {lat: 40.352310, lng: 47.999462},       
      mapTypeId: google.maps.MapTypeId.TERRAIN
    });
  //end oof initMap function
  //------------------------------------------------------------------
  // Define the LatLng coordinates for the Shusha polygon's path.
  var shushaCoords = [
  {lng:46.5852069,lat:39.7918524},
  {lng:46.5810012,lat:39.789016},
  {lng:46.5800569,lat:39.7812995},
  {lng:46.5741348,lat:39.7757586},
  {lng:46.5720748,lat:39.7722619},
  {lng:46.571817,lat:39.763026}
  ];
  // Define the LatLng coordinates for the Khojavend polygon's path.
  var khojavendCoords = [
  {lng:46.6707802,lat:39.5735368},
  {lng:46.6646003,lat:39.5704934},
  {lng:46.6628837,lat:39.5675823}
  ];
  // Define the LatLng coordinates for the Zangilan polygon's path.
  var xocaliCoords = [
  {lng:46.6195822,lat:39.233882},
  {lng:46.6161489,lat:39.232918},
  {lng:46.6094971,lat:39.2322199},
  {lng:46.6076088,lat:39.2318542},
  {lng:46.6009998,lat:39.229494}
  ];
  **and so on for 69 more areas then come the polygons**
  
  **// Construct the xocali polygon.**
  var xocali = new google.maps.Polygon({
      map: map,
      paths: xocaliCoords,
      strokeColor: '#000000',
      strokeOpacity: 0.5,
      strokeWeight: 2,
      fillColor: '#00CCFF',
      fillOpacity: 0.15
    });
  **//and then 68 more** 
  // Add a listener for the julfa mouseover/mouseout event.
  google.maps.event.addListener(julfa ,'mouseover',function(){
  this.setOptions({fillColor: "#00FF00"});
  }); 
  **//here I would like to add a popup where the AREA will be calculated**
  google.maps.event.addListener(julfa ,'mouseout',function(){
  this.setOptions({fillColor: "#00CCFF"});
  });  
  //and then 68 more sets of listeners
  }
   &lt;/script&gt;
  &lt;!--end of mapping script--&gt;
  &lt;!--the script below is the googleAPI browser script, if i need to display on     the server - must change to Server API code.--&gt;
      &lt;script async defer src="https://maps.googleapis.com/maps/api/js?    key=xxxxxxxxxxxxxxxxx&amp;signed_in=true&amp;callback=initMap"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>so I have 3 issues here:
   1. to be able to construct a formula that calculates the area based on the lat lng values for each of the polygons
   2. have this done in a popup
   3. possible to use external .js file</p>