function centerOnMap(lat, lng) {
  map.setCenter(new GLatLng(lat, lng));
}

function getZoomFromRange(range, minZoom) {
  var x = $('map').getComputedStyle('width').toInt();
  var y = $('map').getStyle('height').toInt();
  var zoom = 18 - Math.log((3.3*range)/Math.sqrt(x*x + y*y))/Math.log(2);
  return Math.max(zoom.toInt(), minZoom);
}

function showMapTooltip(marker) {
  var tooltip = $('mapTooltip');
  tooltip.innerHTML = marker.tooltip;

  var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());
  var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
  var anchor=marker.getIcon().iconAnchor;
  var shadowWidth=marker.getIcon().shadowSize.width;
  var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - point.x + shadowWidth, offset.y - point.y -anchor.y));
  pos.apply(tooltip);

	tooltip.setStyle('visibility', 'visible');
}

function hideMapTooltip() {
  $('mapTooltip').setStyle('visibility', 'hidden');
}