-1

I'm a new web developer and trying to get an embedded Google map on a website for my client. When I test the .html files on my machine and others too it works perfectly but when I run the website on the hosting service and domain that I bought from godaddy.com the map does not work...

Anyone have any thoughts on how to fix this. The google map embed code is below if that helps. Thanks in advance.

<div id="googleMap"></div>

<script src="http://maps.googleapis.com/maps/api/js"></script>
<script>
var myCenter = new google.maps.LatLng(40.289696, -111.720798);

function initialize() {
var mapProp = {
center:myCenter,
zoom:12,
scrollwheel:false,
draggable:false,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);

var marker = new google.maps.Marker({
position:myCenter,
});

marker.setMap(map);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
Kapetan
  • 3
  • 1
  • Any error in console? – Rohit Jul 14 '16 at 04:53
  • Keys are now required. Possible duplicate of [Google geocoder throwing MissingKeyMapError on one page but not another](http://stackoverflow.com/questions/38269149/google-geocoder-throwing-missingkeymaperror-on-one-page-but-not-another/38270471#38270471) – geocodezip Jul 14 '16 at 05:16
  • I had put the key, the issue was improper setup of the initialize and load JS functions. Thanks for all the comments. They are alway highly appreciated. – Kapetan Jul 28 '16 at 19:22

1 Answers1

0

Try this,

<script
src="http://maps.googleapis.com/maps/api/js">
</script>

<script>
     function initialize() {
        var mapProp = {
          center:new google.maps.LatLng(51.508742,-0.120850),
          zoom:5,
          mapTypeId:google.maps.MapTypeId.ROADMAP
        };
       var map=new google.maps.Map(document.getElementById("googleMap"), mapProp);
     }
     google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
   <div id="googleMap" style="width:500px;height:380px;"></div>

</body>
</html>
Miu 1994
  • 28
  • 5