Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    May 2014
    Posts
    19

    Question Unanswered: Using Google Maps to calculate distance in Brilliant

    OK, here is what I need to do, and since I am new to brilliant, I am not sure IF it can be done.

    I want to have a STATIC starting location, maybe as a hidden field, since the trucks will be dispatched from that location.

    I then want BDB to look at the pickup address, calculate using Google Maps or maybe Mapquest or Bing, the distance from the start location to the pickup address, and auto populate a field in the DB.

    I don't need to show the Map in BDB.

    Does anyone know if this is feasible or possible?

    Thanks

  2. #2
    Join Date
    Jun 2012
    Posts
    163
    Provided Answers: 1
    brilliant has not a way to do it directly...
    but...

    your answer is not in brilliant, is in the google api... what you need to achieve is ask the distance to the google maps api, and then, save that info somewhere, for example in a file, and then, make brilliant to read the file and so on...

    but... you need to get your hands dirty with the google maps api.

    theres is a nice guy in this forum that made some google maps stuff in brilliant i would ask him where to begging.

    but in general speaking you should investigate about google maps api.

    best regards

    fer from mexico

    (api= aplication interface)

  3. #3
    Join Date
    May 2014
    Posts
    19
    Thanks! I was kinda afraid of that

  4. #4
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Hello.
    You need to send a request to googles distance matrix API.

    For example, you would send a URL request that would force a webpage at google to display the information you require in XML format.

    So for example, I live in Waterford Ireland, and I want to find out how far it is to Dublin Ireland.

    So this is the exact URL Request you would send.

    Code:
    http://maps.google.com/maps/api/distancematrix/xml?origins=Waterford|Ireland&destinations=Dublin|Ireland&mode=driving&sensor=false
    Go ahead, copy the code into your browser and see. It will display the data in XML format. Now all you need to do is parse the URL address for the information you want brilliant database to import.

    In this case it will be the value before the following tag.

    Code:
     km</text>
    This value is the total journey distance.

    You can even go much further on all this and get Google's Directions "Turn by Turn" API to give turn by turn instructions for each leg of the journey, and even how long each leg will take in time and distance.

    You could then parse all the different lines into a clear guide for your drivers to follow.

    For example, drop this url into your browers and a google xml page will spit out the entire route, turn by turn from my City of Waterford to Dublin Ireland.

    Code:
    http://maps.google.com/maps/api/directions/xml?origin=[Waterford, Ireland]&destination=[Dublin, Ireland]&sensor=false&units=metric&mode=driving
    Hope that helps. If you google "distancematrix api" and google "directions api" you can find a list of other tags you can add to the lines above. Things like changing distance to miles, setting the language the information is displayed in and so on. You can even specify how you are getting from point A to B. Walking, Car, Buss and so on. This will recalculate the time.

    Regards
    James
    Last edited by Tubbritt; 05-20-14 at 21:14.

  5. #5
    Join Date
    May 2014
    Posts
    19

    Thumbs up Re: Google Maps

    Many Thanks James! This at least points me in the right direction. My only thing is getting the API to pick up from the field Pickup Address the destination, instead of just city to city as in your example.

    Enjoy a Guinness for me!

    Larry

  6. #6
    Join Date
    Jun 2012
    Posts
    163
    Provided Answers: 1
    Dear @james that was awsome... i would be something like excesive brutal geekness

    best regards and thanks for the class... i think i could use it later.

    best regards

    fer from mexico

  7. #7
    Join Date
    Jun 2012
    Posts
    163
    Provided Answers: 1
    by the way... if some you (larry) do some achievement in brilliant please... share it

    i am curious about, how to read the google answer and put the info into a field...

    james if you know how, and if it dont takes you a grate efford, could be nice if you tell us how do you "read" the specific tag <km> into brilliant...

    best regards

    fer

  8. #8
    Join Date
    May 2014
    Posts
    19
    Quote Originally Posted by ferslash View Post
    by the way... if some you (larry) do some achievement in brilliant please... share it

    fer
    I will always be glad to share any knowledge I achieve

    Larry

  9. #9
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    My only thing is getting the API to pick up from the field Pickup Address the destination, instead of just city to city as in your example.
    You can go door to door if you like. Just expand on what I've given you.

    For example, here's an example of how long it will take to get from a house on a known street in my city to a shop that sells Camera's in Dublin City.

    Code:
    http://maps.google.com/maps/api/distancematrix/xml?origins=1 Cannon Street, Waterford, Ireland&destinations=Camera Centre, Grafton Street, Dublin, Ireland&mode=driving&sensor=false
    Enjoy a Guinness for me
    lol... Sure will.

    Regards
    James

  10. #10
    Join Date
    May 2014
    Posts
    19
    That is what I needed! I can rock with it now!!!!

    Again, drink several pints for me James!!!


  11. #11
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    james if you know how, and if it dont takes you a grate efford, could be nice if you tell us how do you "read" the specific tag <km> into brilliant
    It's no problem for me to do, but it's not something easy to explain by typing text instructions. The parse function generates a script by you selecting marker points. It's a million times easer to explain how it works in a video as you can see the script being generated vs trying to explain something by text.

    Basically though you can set the parse import function to look for start and end values of your choice and you can the data between your points (as many start and end blocks as you like) to Fields in your Database.

    So for the total distance in this case I would be setting the first start marker as
    Code:
    <distance>[br]
    </value>
    And the end marker as

    Code:
    <Text>
    And I will not direct that data to any field the database.

    This means that the first start and end markers go nowhere, and I've only used them to get to the lines of the XML I want which in this case we are now right at the Km numeric value.

    So I will set the next start marker as nothing, (meaning I want everything from the point we are at), and I will send the end marker as </text>

    At this stage the actual distance numeric value as well as the letters km are now available and you can redirect that to whatever field you want on your database.

    Job done.

    Regards
    James

  12. #12
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Quote Originally Posted by Papooh View Post
    That is what I needed! I can rock with it now!!!!

    Again, drink several pints for me James!!!

    Great stuff.
    Any problems just let me know.

    Regards
    James

  13. #13
    Join Date
    May 2014
    Posts
    19

    Question Almost got it...i think

    OK I almost having it parsing successfully EXCEPT for one little hiccup in the output.

    <?xml version="1.0" encoding="UTF-8"?>
    <DistanceMatrixResponse>
    <status>OK</status>
    <origin_address>6702 Crestridge Street, Houston, TX 77033, USA</origin_address>
    <destination_address>REDACTED FOR USER SAFETY, USA</destination_address>
    <row>
    <element>
    <status>OK</status>
    <duration>
    <value>2908</value>
    <text>48 mins</text>
    </duration>
    <distance>
    <value>52404</value>
    <text>32.6 mi</text>
    </distance>
    </element>
    </row>
    </DistanceMatrixResponse>

    What I am trying to figure out is this:

    All I need is the mileage, but when I try to use the import/parse function no matter how many times I remove text or tags, it won't output just the miles, as in this example 32.6 So I am confused as to what I am NOT doing right.

    Using BDB 10.06. For some reason, it doesn't seem to want to replace exactly what I wan.

    Any suggestions?


  14. #14
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Using BDB 10.06
    I don't know if that will open one of my v10.54 files so I'll write this in version 9 for you. That way when you go to open the file, your v10.06 will convert it to your format and you should have no problem opening the file.

    Ok.... so see attached file for a fully working example. Enter in any Starting Point address and Destination Address and it will tell you how many miles it is between the two points.

    Regards
    James
    Attached Files Attached Files

  15. #15
    Join Date
    May 2014
    Posts
    19

    Thumbs up

    Quote Originally Posted by Tubbritt View Post
    I don't know if that will open one of my v10.54 files so I'll write this in version 9 for you. That way when you go to open the file, your v10.06 will convert it to your format and you should have no problem opening the file.

    Ok.... so see attached file for a fully working example. Enter in any Starting Point address and Destination Address and it will tell you how many miles it is between the two points.

    Regards
    James
    OK I must be blind (actually I do wear glasses) and I see it works. What I do not see is the code itself that makes it work. I will keep digging and see if I can find it. Once I do I should not have a problem making it do what I need.

    I ALMOST have it all done

    And once again, a few pints of Ireland's finest to you



    OK Now I found it, it was in the Parser script! DOH!
    Last edited by Papooh; 05-21-14 at 09:03. Reason: Found Answer

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •