Jump to content
Server Maintenance This Week. ×

Webviewer grabbing mileage info from mapquest


Answers

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

Recommended Posts

I want to have a webview that uses either mapquest or google maps that shows the mileage between two locations, based on "To" & "From" fields in Filemaker. I'm having trouble figuring out how the syntax works.  I do have on another layout with a webviewer that interacts with a website and information is fed to & from filemaker so I know it's possible.

 

To sum it up, I want mapquest via filemaker to take the city, state from & to and feed me back the mileage.

 

Any help or guidance would be greatly appreciated!

 

Thank you,

 

Caroline

Link to comment
Share on other sites

I'm not sure about MapQuest.  I've never tried to use it.  I assume you're actually trying to insert mileage into a field.  If so, you can use GoogleMaps API to return either a JSON or XML string and parse the string for the distance.  I've only ever attempted parsing XML with custom functions.  The custom functions I use came from one of the starter solutions that come with FM12.

 

The distance is returned as an element called "distance".  It has two child elements called "text" and "value".  The "text" comes back as "XX.X mi".  The "value" comes back as an integer in meters.  I would grab this and then convert it to miles (or whatever you want).

 

This is the format for the url you would use:

 

"http://maps.googleapis.com/maps/api/directions/xml?origin=" & TableName::FromField & "&destination=" & TableName::ToField & "&sensor=false"

 

Just feed your "From" field in as the "origin=" parameter and your "To" field as the "destination=" parameter.  

Click HERE to see an example of the results you would get back if you used San Antonio as an origin and Austin as the destination.

 

If you have FM12, it can be done via scripting with a global field and the "Insert From URL" script step.  

 

If you're running a prior version, then you'll have to use a web viewer and parse the results out of that.

 

It's a bit complicated, but it can be done.

Link to comment
Share on other sites

Thank you so much for your reply. They are not using Filemaker 12 as of yet (11). So I put a web viewer on the layout that automatcially display the current origin , destination from the current filemaker record. And at times it's a multicity route. This is working for now. As they move from record to record (in this case loads, it's a logistics company) it displays the results. Also they can view the directions right there. It Can however be a tad slow at times. I might try doing it as you suggested.

Link to comment
Share on other sites

Hi,

I would like to use this method for a client. Do you know of a way to get the XML text out of the Web Viewer and into an FM text field for parsing in FM 11 using a script? All I can get is the ridiculous mess of HTML using GetLayoutObjectAttribute.

 

Thanks for the tip!

Link to comment
Share on other sites

This topic is 4046 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.