// Author: Thomas Høi - it-arkitekterne.dk

// Scripts snippets shared

// -------------------------------------------------------------------------------------------
// gmapCenterAndZoom - Centers and zooms map so that the bounding rectangle will be displayed.
function gmapCenterAndZoom(gmap, minLat, maxLat, minLng, maxLng) {
   try {
      //noinspection JSUnresolvedFunction
      var swPoint = new GLatLng(minLat, minLng);
      //noinspection JSUnresolvedFunction
      var nePoint = new GLatLng(maxLat, maxLng);
      //noinspection JSUnresolvedFunction
      var latLngBound = new GLatLngBounds(swPoint, nePoint);
      //noinspection JSUnresolvedFunction
      var center = new GLatLng((minLat + maxLat) / 2, (minLng + maxLng) / 2);
      //noinspection JSUnresolvedFunction
      var zoom = gmap.getBoundsZoomLevel(latLngBound);
      //alert("zoom=" + zoom);
      //noinspection JSUnresolvedFunction
      gmap.setCenter(center, zoom);
   } catch (e) {
      alert(e);
   }
}
