Error showing Google map in website

i am using a html template for my website. Google maps works fine in my localhost but when i upload it on server it show error on showing google maps.

i tried using google api key,but it still not working and getting javascript error on screen.

Please find attached pic for your reference.

Please advice what should i do.

Error while loading maps

Upvotes: 0

Views: 424

Answers (1)

Prashanth Reddy
Prashanth Reddy

Reputation: 745

Maps.html

Replace the key for googlemaps API

<!DOCTYPE html>
<html>    
<body>    
<div id="map" style="width:100%;height:500px"></div>

<script>
function myMap() {
  var text="hello";
  var myCenter = new google.maps.LatLng(51.508742,-0.120850);
  var mapCanvas = document.getElementById("map");
  var mapOptions = {center: myCenter, zoom: 5};
  var map = new google.maps.Map(mapCanvas, mapOptions);
  var marker = new google.maps.Marker({position:myCenter});
  marker.setMap(map);
  google.maps.event.addListener(marker,'click',function() {
    var infowindow = new google.maps.InfoWindow({
      content: text
    });
  infowindow.open(map,marker);
  });
}
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=REPLACEKEY&callback=myMap"></script>
</body>
</html>

Upvotes: 2

Related Questions