Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I don't see anything wrong, but the map will not appear (using gmaps.js from github)

I'm trying to use the GMaps.js in github but for some reason it is not working, I'm pretty sure I have typed it out right, if anybody could point me in the right direction thanks. (http://i.imgur.com/3LkL6xS.png actual photo in case it isn't big enough on here.)

Broken Code

Here is the new source code:

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://maps.google.com/maps/api/js?key=AIzaSyBi7e8AiTyqWiFt9vlbGqsAzGyRhVWqCsk&sensor=true"></script>
<script src="js/gmaps.js"></script>
<script>
/**
  * Basic Map
  */
$(document).ready(function(){
 var map = new GMaps({
    div: '#basic_map',
    lat: 51.5073346,
    lng: -0.1276831,
    zoom: 12,
    zoomControl : true,
    zoomControlOpt: {
        style : 'SMALL',
        position: 'TOP_LEFT'
    },
    panControl : false,
  });
});
</script>
</head>
<body>
<div id="basic_map"></div>
</body>
</html>
like image 604
Datsik Avatar asked Mar 03 '13 08:03

Datsik


1 Answers

As I said in the comment, you are probably missing the width and height of the div, you try show map in.

Here is working jsfiddle: jsFiddle to play with

$(document).ready(function () {
    var map = new GMaps({
        div: '#basic_map',
        lat: 51.5073346,
        lng: -0.1276831,
        width: '500px',
        height: '500px',
        zoom: 12,
        zoomControl: true,
        zoomControlOpt: {
            style: 'SMALL',
            position: 'TOP_LEFT'
        },
        panControl: false
    });
});

Added width and height to the code.
Or Here you have the same result, with width and height in css. Not much difference.

like image 124
Kedor Avatar answered Oct 24 '22 05:10

Kedor