title: how to set zoom level/view of leaflet map
body: <p>I have a map in <code>leaflet</code> in RShiny which have markers plotted and once I click a marker it adds circles to map showing all the related points to the marker. </p>
  
  <p>What I want to do is to set zoom/view of the map in such a way that all the related circles are visible.</p>
  
  <p>The number of circles varies as per markers i.e. some marker have 1 or 2 circles while some have more. Also, the location of circles varies across the USA so they can be placed in one city or another state.</p>
  
  <p>Following is the code I am using to add circles to existing map</p>
  
  <pre><code>  proxy &lt;-leafletProxy("map",data = df)%&gt;%
    clearMarkers()%&gt;%
    addCircleMarkers(lat = ~lat,lng = ~lng,layerId = ~circle_pt,fillColor = 
   'green',opacity = 0.5,color = 'red',fillOpacity = 1)%&gt;% clearPopups()%&gt;%
    addPopups(lat=~lat,lng=~lng,~as.character(circle_pt))
  </code></pre>
  
  <p>map=original map with markers
  df=lat lng of circles with associated properties of selected marker in map</p>
  
  <p><img src="https://i.stack.imgur.com/rblDD.png" alt="original map where markers are shown"></p>
  
  <p><img src="https://i.stack.imgur.com/3ZANI.png" alt="circles are shown on marker click event"></p>
  
  <p>I want to set zoom level as shown in figure 2.</p>
  
  <p>Kindly help me to identify how to calculate optimal zoom level in leaflet in <code>shiny</code>.</p>
  
  <p>Regards,</p>