Accessing API key from custom label and also adding script tags in skuid javascript snippet

edited January 2019 in Questions
We are doing geo coding on our records by calling google api from skuid javascript snippet, we want to include api key as well in the request.

function load_map_from_address(mapid, address) {          // check if gps has been locally cached.               geocoder = new google.maps.Geocoder();          //alert(geocoder);          var geocoderAPIKey = 'geocoderAPIKey ';          geocoder.geocode({ 'address': address }, function (results, status) {              //alert(status);              if (status == "OK") {                    var gps = results[0].geometry.location;                  create_map(gps.lat(), gps.lng(), mapid);              }              else {                  $('#' + mapid).html('<div class="map_canvas_text "><h4>address not found</h4></div>').show();                }          }); 
}

Am looking for a way to add below script tag in the javascript snippet where we are calling geocode method and also want to access api key using custom label..

 <script              src="https://maps.googleapis.com/maps/api/js?key={!$Label.GoogleAPIKey}&callback=initialize"> 
                </script>

Comments

  • edited January 2019
    Praveen,

    In your Skuid Page Builder, add a JavaScript Resource of type 'External'.  You can then add the URL for the Google API.



    Thanks,

    Bill
  • edited January 2019
    Thanks Bill. I have api key in custom setting, is there any way to point it there.

  • edited January 2019
    Praveen,

    You can create a model to load your custom setting.  I am not sure if the model will load before Skuid attempts pull in the external resource.

    Thanks,

    Bill
Sign In or Register to comment.