title: Finding the center of Leaflet polygon?
body: <p>I have a bunch of leaflet polygons on a map I created. Each polygon represents something different. A specific set of information is displayed in a popup depending on the page the user is on. I need to find a way to make the "popup" bubble open in the center of the polygon it represents. </p>
  
  <p>Each polygon is drawn using the following code:</p>
  
  <pre><code>var L20 = [
      [74.0995, -99.92615],
      [74.14008, -99.4043],
      [74.07691, -99.33838],
      [74.03617, -99.86023]
  ];
  
  
  
  var L19 = [
      [74.02559, -99.84924],
      [74.06636, -99.32739],
      [74.0029, -99.26147],
      [73.96197, -99.77783]
  ];
  
  var L18 = [
      [73.95142, -99.76684],
      [73.99235, -99.25048],
      [73.92889, -99.18456],
      [73.8878, -99.69543]
  ];
  
  var set1 = L.polygon([L20, L19, L18], {
      color: "#fff",
      weight: 1,
      stroke: true,
      opacity: 0.05,
      fillColor: "#346B1F",
  
  }).addTo(map);
  </code></pre>
  
  <p>The popup is drawn using the following code:</p>
  
  <pre><code>var popup = L.popup({})
      .setLatLng([73.64017, -100.32715])
      .setContent(content).openOn(map);
      var popup = L.popup();
  </code></pre>
  
  <p>So I need to find a way for <code>.setLatLang</code> to determin or be given the center of the polygon.</p>
  
  <p>I came up with 3 solutions that may work, not sure how to go about it.</p>
  
  <ol>
  <li><p>find a way to use the coordinates of a polygon to determine the center of the polygon where the popup will open.</p></li>
  <li><p>call one point of the polygon, then offset the position of the popup.</p></li>
  <li><p>Use an id for each polygon, so each popup knows the box area (polygon) it can be opened in.</p></li>
  </ol>
  
  <p>Can someone help me please?</p>