Jump to content
Server Maintenance This Week. ×

Calculate distance between 2 addresses


This topic is 3530 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hello can someone please tell me how I can return a value that is the Kilometres between two addresses.

The addresses are from my database are Starting Address and Destination address. I don't need travelling directions, just the calculated distance. Preferably using Google maps Australia

I have FM8

 

 

Link to comment
Share on other sites

The question is not quite clear: if you want to get the distance from Goggle each time you need it, then there is no calculation of distance involved (at least not on your part).

 

OTOH, if you want to calculate the distance yourself, then you will need each address to have a latitude and a longitude. If you're using version 8 (i.e. no web viewer), then perhaps you should look into that.

Link to comment
Share on other sites

  • Newbies

Sorry I didn't make my self very clear. I have address  fields ie Street, Suburb,State, for the departures and another fields ie Street, Suburb,State for the arrivals. What I would like to do it press a script button that would return the distance in a different field. With this information I can workout a delivery cost. Hope that helps.

 

I am thinking of upgrading to FM13 but at the moment I have Windows Vista and FM13 wont work

Link to comment
Share on other sites

This is going to take some work. First, study the Google Maps Distance Matrix API  to find out how to calculate the URL for the HTTP request from your data. To get the response into a field, you will need to import it, using Import Records from XML source. For this, you will also need an XSLT stylesheet to transform Google's XML to Filemaker's grammar.

 

Note that Filemaker (< v.13) can only import XML from an HTTP request, not HTTPS.

Link to comment
Share on other sites

Hi Keith, and welcome to the FM Forums,

 

I moved your topic from "FileMaker Legacy Versions 7 – 9" to "Calculation Engine (Define Fields)” because, the General Topics, including FileMaker Legacy Versions, are restricted to questions about the tools, functions and features that were introduced in the version named, and not for asking How-To questions.

 

We have this topic for Calculation Questions.

 

Lee

Link to comment
Share on other sites

I am thinking of upgrading to FM13 but at the moment I have Windows Vista and FM13 wont work

 

When you do get around to upgrading to 13, this process can get a little easier (if you don't already know XSLT) because you'll have the Insert From URL script step available to you. You'll be able to request XML or JSON as you prefer and parse the result with FileMaker's own text functions. This blog post describes the process.

 

Does your application also show locations on a Google Map? You'd be violating Google's license terms to use the Distance Matrix API (or any other from the Google Maps family of APIs) and not include a Google Map in your application. The MapQuest Route Matrix API is an alternative to Google's Distance Matrix API with different licensing restrictions.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Very nice solution! I'm wondering if it's possible to pull the distance value from a map that is currently in the web viewer. i.e. the user might have used a different route to the one that Google Maps proposes (but same origin and destination). Therefore it would be great if the user could define the route they took by dragging the nodes within google maps on the web viewer, which then outputs the new distances.

Link to comment
Share on other sites

  • 1 month later...

I keep finding responses telling us that the Google Distance API must be displayed in a Map for licensing purposes, but not how to accomplish this in FileMaker.

 

I'm writing an application that pulls the API information into a text field so I can get the distance value (JSON) but I haven't figured out how to get this to the web viewer for displaying the route. Can someone please post an example of how this works?

 

Thanks

Link to comment
Share on other sites

Answered my own question with a workaround. The agreement is that the data captured from the API must be used in a MAP but it doesn't specify how that data gets to the map. So I created a Web Viewer object and via a script, I represent the same query via Googles standard map display:

"https://www.google.com/maps/dir/" & <Table>::MAP_City_Start & "+" & <Table>::MAP_ST_Start & "/" & <Table>::MAP_City_End & "+" & <Table>::MAP_ST_End

Since the data returned via the JSON is identical to the data via google/maps in a web viewer, it's legally represented.

 

Thanks

Link to comment
Share on other sites

A different way to satisfy the license terms is to choose a service with more lenient license terms. The OpenStreetMap APIs are as loose as it gets, requiring only conspicuous attribution, but OpenStreetMap doesn't have an API for transit distance or directions. However, MapQuest has an "open" version of their directions API based on OpenStreetMap data with similar license terms.

Link to comment
Share on other sites

This topic is 3530 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.