March 22, 201312 yr 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
March 27, 201312 yr 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.
April 3, 201312 yr Author 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.
April 4, 201312 yr 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!
April 5, 201312 yr @daveinc I'm not sure exactly what you are trying to do, but if you look at some of the custom functions available on Brian Dunning's website, or on the Filemaker Custom Functions website and search under HTML or XML, you should find something to help. Brian
Create an account or sign in to comment