2 Replies Latest reply on Feb 18, 2014 3:02 PM by jbante

    Closest Underground


      Does anyone know how to use the Google API or other to find the closest underground/airport to a postcode? I have succesfully done this using 2 postcodes and insert as URL to capture the XML. The distance is then parsed out using a custome function. Using this technique I have looped through the postcodes of around 300 underground stations to find the closest. It works, but Google does not allow more than 2,500 hits on its API before charging large licence fees. Is there a way to do this in one hit or a cheap plug in?

        • 1. Re: Closest Underground

          Store the latitude/longitude of the stations/points you want to compare against (they don't change, so it does not make sense to re-lookup each time). Then make a single call with your current location to get your current latitude and longitude. If you're on FM Go, you can use the built in Location() function to return this data without a call to an API.


          With these two sets of values, you should be able to calculate the distance between your current point and all points while in FileMaker.


          Jeremy Bante has done great work with this kind of stuff before, I'd read up on his blog:


          • 2. Re: Closest Underground

            As Mike says, it may be best to find all your points of interest in advance, then you can use the Haversine formula to find straight-line distances to those points, which is usually good enough for just finding the closest point.


            However, if you want to know how long it will actually take you to get there, Google's Distance Matrix API lets you find distances between more than 2 points at a time.


            You'll also get better results if you use the address for the underground/airport than the postal code. Google's API doesn't mind using postal code for the origin and address or coordinates for the destination.