Questions

When using google maps javascript api , the maps work perfectly on localhost but it doesn't work on live website .

0

I am trying to put google maps on my website, I am using google maps javascript api for that.
Here is my code.

<!-- Google Map Section -->
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>

It works fine on localhost but doesn’t show on live website.



asked 1 year, 10 months ago
Reputation: 1





1 Answer

0

To make google map visible on live website we need to get an api key for google maps from google.

Here are the steps:

  1. Go to Google api console

  2. Then from top left corner select your project there will be 3 options

    • Dashboard
    • Library
    • Credentials
  3. Go to library and select Google Maps Javascript Api and enable it.

  4. Now go to Credentials then click Create credentials and select API key from dropdown.Restrict API key from choices given.

  5. Now you have got the API key.

  6. Now simply put your code like this

<!-- Google Map Section -->
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=Your-API-Key"></script>

and now go to live website, it should show google map now.

answered 1 year, 10 months ago
Reputation: 1





Your Answer

Nothing to preview

Post Answer



Asked:  1 year, 10 months ago
Viewed:  563 times
Active:  1 year, 10 months ago