Follow the steps to setup the google map.
Step 1: Generate API key.
- Get an API key from here.
- Go to the Google API Console.
- Create or select a project.
- Click Continue to enable the API and any related services.
- On the Credentials page, get an API key (and set the API key
restrictions).
Step 2: Create configuration file to add the below Javascript file.
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
Configuration file
To do this use the same script or link XML as normal but include src_type="url". As noted in the documentation
<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" src_type="url"/>
</head>