I used checkout ConfigProviderInterface to achieve this task.
Created the di.xml file under Ayakil/GoogleMapAddressLookup/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments>
<argument name="configProviders" xsi:type="array">
<item name="google_map_key" xsi:type="object">Ayakil\GoogleMapAddressLookup\Model\GoogleMapApiKey</item>
</argument>
</arguments>
GoogleMapApiKey.php file content
<?php
namespace Ayakil\GoogleMapAddressLookup\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;
class GoogleMapApiKey implements ConfigProviderInterface
{
public function __construct(ScopeConfigInterface $scopeConfig)
{
$this->scopeConfig = $scopeConfig;
}
public function getConfig()
{
$additionalVariables['Google_key'] = $this->scopeConfig->getValue("googlemapaddresslookup/general/googleapikey");
return $additionalVariables;
}
}
In the js file i got the setup variable as below
**window.checkoutConfig.Google_key**
'https://maps.googleapis.com/maps/api/js?key='+window.checkoutConfig.Google_key+'&libraries=places'