function toRad(num) { return num * Math.PI / 180; }, function toDeg(num) { return num * 180 / Math.PI; }, function destinationPoint(LatLng, bearingDegrees, radiusMeters) { dist = radiusMeters / 1000 // convert to KM dist = dist / 6371; //Radius of earth approx bearingDegrees = this.toRad(bearingDegrees); var lat1 = this.toRad(LatLng.lat()), lon1 = this.toRad(LatLng.lng()); var lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + Math.cos(lat1) * Math.sin(dist) * Math.cos(bearingDegrees)); var lon2 = lon1 + Math.atan2(Math.sin(bearingDegrees) * Math.sin(dist) * Math.cos(lat1), Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2)); if (isNaN(lat2) || isNaN(lon2)) return null; return new google.maps.LatLng(this.toDeg(lat2), this.toDeg(lon2)); } function extendMapToFit(map, pos, radius){ var center = new google.maps.LatLng(pos.lat, pos.lng); var bounds = map.getBounds(); bounds.extend(destinationPoint(center, 90, radius )); bounds.extend(destinationPoint(center, -90, radius )); bounds.extend(destinationPoint(center, 180, radius )); bounds.extend(destinationPoint(center, 0, radius )); } }