Keep the center lat / lon point, as well as the distance to the corner (use some trigger to figure this out), and the radius of the earth in meters. Your bearing in degrees will be 45 to give you the top right, 115 for the top left, etc. Use fancy math below to find the lat / long of your desired angle in decimal format. Convert to degrees by multiplying each by 180 / PI
lat1 = centerPoint.lat * ( Math.PI / 180 );
lon1 = centerPoint.lng * ( Math.PI / 180 );
d = distance;
R = EARTHS_RADIUS_IN_METERS;
brng = bearingInDegrees * ( Math.PI / 180 );
lat2 = Math.asin( Math.sin( lat1 ) * Math.cos( d / R ) + Math.cos( lat1 ) * Math.sin( d / R ) * Math.cos( brng ) );
lon2 = lon1 + Math.atan2( Math.sin( brng ) * Math.sin( d / R ) * Math.cos( lat1 ), Math.cos( d / R ) - Math.sin( lat1 ) * Math.sin( lat2 ) );
return new LatLong( lat2 * ( 180 / Math.PI ), lon2 * ( 180 / Math.PI ) );
source
share