Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the conversion of latitude/longitude to a 1 mile [closed]

I'm working with Google Maps and I need to be able to search in a 5 mile radius around a zip code center so I figured the easiest way to do that would be to figure out the conversion of latitude/longitude to miles.

like image 390
Colin Avatar asked Dec 28 '11 16:12

Colin


People also ask

How do you convert latitude and longitude to miles?

One degree of latitude equals approximately 364,000 feet (69 miles), one minute equals 6,068 feet (1.15 miles), and one-second equals 101 feet. One-degree of longitude equals 288,200 feet (54.6 miles), one minute equals 4,800 feet (0.91 mile), and one second equals 80 feet.

What is the equivalent of one 1 minute of latitude or longitude in kilometer and mile?

One degree of latitude is divided into 60 minutes ('). One minute of latitude equals one nautical mile , which is equal to 1.15 land miles (1.85 km).

How many miles is 2 degrees longitude?

Each degree of latitude is approximately 69 miles (111 kilometers) apart. The range varies (due to the earth's slightly ellipsoid shape) from 68.703 miles (110.567 km) at the equator to 69.407 (111.699 km) at the poles. This is convenient because each minute (1/60th of a degree) is approximately one [nautical] mile.

How many miles is 1 degree longitude at the equator?

The number of degrees of longitude covered if we circumnavigated Earth around the Equator would therefore be 360. However, unlike latitude, lines of longitude converge at the poles, which means that the length of a degree of longitude is not constant. At the Equator, it will be 69.4 miles, just like latitude.


1 Answers

Here is the basic idea using Google's Geometry library.

Remember to add the geometry library. It is separate than the Google maps library.

<script type="text/javascript" 
  src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false">
</script>

example usage:

    //the distance function defaults to km.  
    //to use miles add the radius of the earth in miles as the 3rd param.
    //earths radius in miles == 3956.6
    var distance = 
      google.maps.geometry.spherical.computeDistanceBetween(
            /* from LatLng */, 
            /* to LatLng */, 
            /* radius of the earth */
      );

    if (distance <= 5) { //less or equal to five miles
        var marker = new google.maps.Marker({
            map: map,
            position: //LatLng
        });              
    }

I have an example fiddle of this in action.

like image 185
Bryan Weaver Avatar answered Nov 16 '22 09:11

Bryan Weaver