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

  • 1
  • Question
  • Updated 3 weeks ago
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();

            }
        });&nbsp;
}

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>

Photo of Praveen Pannala

Praveen Pannala

  • 610 Points 500 badge 2x thumb

Posted 4 weeks ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,948 Points 10k badge 2x thumb
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
Photo of Praveen Pannala

Praveen Pannala

  • 610 Points 500 badge 2x thumb
Thanks Bill. I have api key in custom setting, is there any way to point it there.
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,948 Points 10k badge 2x thumb
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