What's the best way to capture the miles between two address in filemaker ?
I'm not sure of the details, but what came to mind was using Google Maps in a webviewer and have it do the calculations then do some data mining to get your result.
Did this last year and something changed at google's api....my code is no longer working. Hoping for a new simpler solution...
Driving miles or "crow flies"?
For driving, I use this calculation in Insert from URL to get the page from Google:
url.start = "http://maps.googleapis.com/maps/api/directions/xml?origin=" ;
start.address = CONTACTS::Street Address & " " & CONTACTS::City & " " & CONTACTS::State & " " & CONTACTS::Zip ;
url.middle= "&destination=" ;
url.end = "&sensor=false";
result = url.start & start.address & url.middle & end.address & url.end
And then pass that as the xml parameter to this function to grab the mileage:
end = Length ( xml ) ;
openTag = "<distance>" ;
closeTag = "</distance>" ;
PosOpenTag = Position ( xml ; openTag ; end ; -1 ) ;
PosCloseTag = Position ( xml ; closeTag ; end ; -1 ) ;
XMLdistance.distance = Middle ( xml ; PosOpenTag + Length ( OpenTag ) ; PosCloseTag - PosOpenTag - Length ( closeTag) ) ;
openTag = "<text>" ;
closeTag = "</text>" ;
PosOpenTag = Position ( XMLdistance.distance ; openTag ; end ; -1 ) ;
PosCloseTag = Position ( XMLdistance.distance ; closeTag ; end ; -1 ) ;
XMLdistance = Middle ( XMLdistance.distance; PosOpenTag + Length ( OpenTag ) ; PosCloseTag - PosOpenTag - Length ( closeTag) ) ;
result = Filter ( XMLdistance ; "0123456789." )
Thank you for sharing...
this is working like a charm....thank you so much Daivd..
Retrieving data ...