title: In Leaflet.js, how do you focus the map on a polygon that is being highlighted by external JS?
body: <p>How does one focus the map on a location? </p>
  
  <p>My setup is based on this post:<br>
  <a href="https://stackoverflow.com/questions/32971673/how-do-you-make-a-highlighted-outline-appear-in-leaflet-js-on-mouseover-and-by-h">How do you make a highlighted outline appear in leaflet.js on mouseover and by hyperlink?</a></p>
  
  <p>I have a list of links on the side of the page in a different layer and have set it up to allow the map to highlight a building when the link is clicked, but would also like to move the focus of the map to that building.</p>
  
  <p>So for this code:</p>
  
  <pre><code>function setHighlight (layer) {
    // Check if something's highlighted, if so unset highlight
    if (highlight) {
      unsetHighlight(highlight);
    }
    // Set highlight style on layer and store to variable
    layer.setStyle(style.highlight);
    highlight = layer;
  }
  </code></pre>
  
  <p>I want to additionally focus on the polygon calling the function. For instance:</p>
  
  <pre><code>var group = new L.LayerGroup([
  new L.Polygon([
      [-50, -50], [50, -50], [50, -10], [-50, -10]
  ], {
      'label': 'Polygon 1',
      'popup': 'Polygon 1'
  }),
  new L.Polygon([
      [-50, 10], [50, 10], [50, 50], [-50, 50]
  ], {
      'label': 'Polygon 2',
      'popup': 'Polygon 2'
  })
  ]).addTo(map);
  </code></pre>
  
  <p>Is there a definition to add to the polygon to indicate its position? Or is there code that can focus the map on the center of the polygon?</p>
  
  <p>Thanks!</p>