client/locations-list-map.js
/**
 * Fits map to bounds, expanding the bounds to include at least three markers as necessary.
 */
Fits map to bounds, expanding the bounds to include at least three markers as necessary.
Fits map to bounds expanding the bounds to include at least three markers as necessary .
function fitMapToMarkersNearBounds(bounds) {
  const center = bounds.getCenter();
  const markersByDistance = getMarkersByDistanceFrom(center.lat(), center.lng(), 3);
  markersByDistance.forEach((marker) => {
    bounds.extend(marker.position);
  });
  if (!bounds.getNorthEast().equals(bounds.getSouthWest())) {
    gMap.fitBounds(bounds);
  } else {
    gMap.setCenter(center);
  }
}
function fitMapToMarkersNearBounds ( bounds ) { const center = bounds . getCenter ( ) ; const markersByDistance = getMarkersByDistanceFrom ( center . lat ( ) , center . lng ( ) , 3 ) ; markersByDistance . forEach ( ( marker ) => { bounds . extend ( marker . position ) ; } ) ; if ( ! bounds . getNorthEast ( ) . equals ( bounds . getSouthWest ( ) ) ) { gMap . fitBounds ( bounds ) ; } else { gMap . setCenter ( center ) ; } }
Fits map to bounds, expanding the bounds to include at least three markers as necessary.
Fits map to bounds expanding the bounds to include at least three markers as necessary .
// get center of bounding box and use it to sort markers by distance // extend bounds to fit closest three markers // zoom to fit user loc + nearest markers // just has user loc - shift view without zooming