Oct 06

The Spherical law of cosines gives a pretty accurate result that will be sufficient for most applications.

    lat, longs are in radians
public static double distance(double lat1, double lon1, 
                                              double lat2, double lon2) {
    return R * Math.acos(Math.sin(lat1) * Math.sin(lat2) +
        Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon1 - lon2));

private static final double R = 6371.0;  // earths mean radius in km

written by objects \\ tags: , ,

Apr 05

Sometimes we need to get the latitude and longitude of a point in Google Maps but Maps does not display them, so how do we get them?

Turns out its pretty simple. First centre your map on the point of interest, then type the following javascript into the location bar of your browser and hit return (this will execute the javascript code).


You should get a popup displaying the latitude and longitude of the centre of the map.

We find this particularly useful when adding maps to web sites and we need finer control over centering the map, or adding markers.

written by objects \\ tags: , , ,