bien eso es muy complicado. para una caja áspera intente esto:
if (typeof(Number.prototype.toRad) === "undefined") {
Number.prototype.toRad = function() {
return this * Math.PI/180;
}
}
if (typeof(Number.prototype.toDeg) === "undefined") {
Number.prototype.toDeg = function() {
return this * 180/Math.PI;
}
}
var dest = function(lat,lng,brng, dist) {
this._radius = 6371;
dist = typeof(dist) == 'number' ? dist : typeof(dist) == 'string' && dist.trim() != '' ? +dist : NaN;
dist = dist/this._radius;
brng = brng.toRad();
var lat1 = lat.toRad(),
lon1 = lng.toRad();
var lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist) + Math.cos(lat1) * Math.sin(dist) * Math.cos(brng));
var lon2 = lon1 + Math.atan2(Math.sin(brng) * Math.sin(dist) * Math.cos(lat1), Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2));
lon2 = (lon2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
return (lat2.toDeg() + ' ' + lon2.toDeg());
}
var northEastCorner = dest(centreLAT,centreLNG,45,10);
var southWestCorner = dest(centreLAT,centreLNG,225,10);
EDITAR
Lo anterior fue que manera de hacerlo allá por 2011 cuando la escribí. En estos días, la API de Google Maps ha llegado a lo bastante. La respuesta de @wprater es mucho más clara y utiliza algunos de los métodos de API más nuevos.
¡Gracias! Esto funcionó para mí: 'var latLng = new google.maps.LatLng (32.79503, -117.24142);/* San Diego */var radius = 2000;/* metros */var circle = new google.maps.Circle ({center : latLng, radio: radio}); var defaultBounds = circle.getBounds(); ' – Ryan
Genial. Buena solución! –