https://github.com/magesuite/google-api/blob/1.x/view/frontend/layout/default.xml
This module allows adding Google API keys that are then passed to the scripts that are based on the google maps service.
Installation
This module is a part of MageSuite metapackage
Installation if metapackage is not used:
composer require "creativestyle/magesuite-google-api" ^1.0.0
Admin settings
Google API keys can be added in:
Stores -> Configuration -> Sales -> Google Api
Settings
Name | Comment |
---|---|
Api Key | https://developers.google.com/maps/documentation/javascript/get-api-key |
Frontend API Key | This key will be exposed on frontend, please make sure it is restricted to known domains in Google API Console settings. |
Frontend
If values for Google API keys are provided the following element is added to the HTML of each page:
<span style="display: none;" id="google-api-settings" data-google-api-key="[value]" data-google-api-language="[value]" data-google-api-region="[value]">
This method of authentication was used before in checkout autocomplete (autosuggest) for addresses, However as this functionality was error prone, it was removed form MageSuite. The review of this part of module is needed.
When google maps should be displayed (f.e. on the store locator page) the following tag is added to the HEAD:
<script src="https://maps.googleapis.com/maps/api/js?key=[value]" src_type="url"></script>
If fetches google maps object and assign it to the global space.
Google maps are used by the MageSuite store locator script and module
(see: theme-creativeshop/src/MageSuite_StoreLocator/web/js/store-locator/store-locator.ts
)
Review of documentation is needed