0

I am trying to implement google maps in to my page. I couldn't able to acheive it. I am just getting an empty container. I am doing something wrong here ?

 <div class="container">
 <div class="map">
 <div id="map-container" class="z-depth-1-half map-container" style="height: 500px;"></div>
 </div>
 </div>

These are the script files

<script type="text/javascript" src="https://maps.google.com/maps/api/js"></script>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
<script>
    var map;
    function initMap() {
      map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: -34.397, lng: 150.644},
        zoom: 8
      });
    }
</script>

5
  • You talk about php and ajax in your question but the code provided shows neither. Can you be more specific? Commented Feb 19, 2018 at 15:18
  • rest of the code contains only the styling part. Commented Feb 19, 2018 at 15:19
  • I couldn't even load the map either way Commented Feb 19, 2018 at 15:20
  • Change this line to: map = new google.maps.Map(document.getElementById('map-container'). Commented Feb 19, 2018 at 15:22
  • You are referencing a wrong map wrapper in your javascript Commented Feb 19, 2018 at 15:22

1 Answer 1

4

Simple: Your script must be: <script async defer src="//maps.googleapis.com/maps/api/js?key=YourApiKey&callback=initMap"></script>

If necessary, post an screen on your console web.

To know more.

Sign up to request clarification or add additional context in comments.

7 Comments

hallo..,it loads for a minute but suddenly "oops,something went wrong" this page didnt load google maps..this is the error
@yuvii_10 maybe API keys??
You need get an key. Acess the site and press "GET KEY"
@JordiCastilla exact!
I guessed so @Jorge but IMHO, this is already a new question :P
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.