Title: Google matrix api
Last modified: February 27, 2019

---

# Google matrix api

 *  Resolved [photodolphin](https://wordpress.org/support/users/photodolphin/)
 * (@photodolphin)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/google-matrix-api/)
 * Can I use Google matrix api in calculated field an how?
    Can I use link like 
   this?
 * [https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=Washington,DC&destinations=New+York+City,NY&key=MyAPI](https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=Washington,DC&destinations=New+York+City,NY&key=MyAPI)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/google-matrix-api/#post-11253936)
 * Hello [@photodolphin](https://wordpress.org/support/users/photodolphin/)
 * The Developer version of the plugin is distributed with “DISTANCE” operations
   module that includes the DISTANCE operation, it is able to determine the distance
   between two addresses using the Google Maps API. Please, visit the following 
   link:
 * [https://cff.dwbooster.com/documentation#distance-module](https://cff.dwbooster.com/documentation#distance-module)
 * Best regards.
 *  Thread Starter [photodolphin](https://wordpress.org/support/users/photodolphin/)
 * (@photodolphin)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/google-matrix-api/#post-11257303)
 * What if I wanted to use my own JS code without Goolge API? Your free version 
   says I can but it is not working.
 *  <script src=”[https://cdn.jsdelivr.net/npm/graphhopper-js-api-client/dist/graphhopper-client.js”></script&gt](https://cdn.jsdelivr.net/npm/graphhopper-js-api-client/dist/graphhopper-client.js”></script&gt);
 * <script>
    window.onload = function() {
 *  var ghRouting = new GraphHopper.Routing({
    key: “my key”, vehicle: “car”, elevation:
   false });
 *  ghRouting.addPoint(new GHInput(47.400905, 8.534317));
    ghRouting.addPoint(new
   GHInput(47.394108, 8.538265));
 *  ghRouting.doRequest()
    .then(function(json) { return json console.log(json);}).
   catch(function(err) { console.error(err.message); });
 *  };
    </script>
 *  Thread Starter [photodolphin](https://wordpress.org/support/users/photodolphin/)
 * (@photodolphin)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/google-matrix-api/#post-11301640)
 * I know function below is working because it prepends distance value to top of
   the page if i click Preview button. But how do I assign it to fieldname?
    Wherever
   I put “return” as described in [https://wordpress.dwbooster.com/includes/calculated-field/equations.html](https://wordpress.dwbooster.com/includes/calculated-field/equations.html)
   does not work. Please help!
 *     ```
       (function(){
       $(document).ready(function(){
   
          $.getJSON("https://graphhopper.com/api/1/matrix?point=40.67472,-73.39333&point=40.762,%20-73.523&type=json&vehicle=truck&debug=true&out_array=distances&key=MyKey", function(result){
              $.each(result, function(i, field){
            $("body").prepend(field[0]);
   
             });
   
         });
       }); 
       })(); 
       ```
   
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/google-matrix-api/#post-11302455)
 * Hello [@photodolphin](https://wordpress.org/support/users/photodolphin/)
 * First, I recommend you to call the code from a “HTML Content” field, using the
   showHideDepEvent event (that ensures the form has been generated)
 *     ```
       <script>
       fbuilderjQuery(document).one('showHideDepEvent', function(){
       var $ = fbuilderjQuery;
       $.getJSON("https://graphhopper.com/api/1/matrix?point=40.67472,-73.39333&point=40.762,%20-73.523&type=json&vehicle=truck&debug=true&out_array=distances&key=MyKey", function(result){
       $.each(result, function(i, field){
            $('[if*="fieldname1_"]').val(field[0]);
       });
       </script>
       ```
   
 * Furthermore, pay attention in the way I’m assigning the returned value to a hypothetical
   field in the form with name fieldname1, so, you should to use this code to assign
   the value to your real field.
 * I’m sorry, but this code is specific to your project, if you need additional 
   support implementing your project, you should request a custom coding service
   through my private website:
 * [https://cff.dwbooster.com/customization](https://cff.dwbooster.com/customization)
 * Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Google matrix api’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [codepeople](https://wordpress.org/support/users/codepeople/)
 * Last activity: [7 years, 2 months ago](https://wordpress.org/support/topic/google-matrix-api/#post-11302455)
 * Status: resolved