John Swaringen
John Swaringen

Reputation: 751

Google Maps API Issue

I'm trying to prototype some plotting on Google Maps API. I've followed the code here and think my code should work, however I get a blank screen. All of the objects have what appears to be the correct data but alas no dice. Any help would be appreciated.

<!DOCTYPE html>
<html>
<head>
<title>Google Maps Test</title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=<key removed>&sensor=false"></script>
<style type="text/css">
</style>
<script type="text/javascript">
function initialize() {
    var myLatLng = new google.maps.LatLng(33.001466, -97.354317);

    var mapOptions = {
        zoom:6,
        center:myLatLng,
        mapTypeId: google.maps.MapTypeId.TERRAIN
    };
    console.log(mapOptions);

    var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
    console.log(map);

    var routeCoordinates = [
        new google.maps.LatLng(33.001466, -97.354317),
        new google.maps.LatLng(33.025001, -97.352171),
        new google.maps.LatLng(33.033219, -97.341700),
        new google.maps.LatLng(33.049321, -97.320414),
        new google.maps.LatLng(33.051335, -97.304020),
        new google.maps.LatLng(33.059464, -97.298355),
        new google.maps.LatLng(33.083919, -97.295609),
        new google.maps.LatLng(33.111314, -97.291918),
        new google.maps.LatLng(33.136042, -97.289257),
        new google.maps.LatLng(33.182818, -97.287111)
    ];
    console.log(routeCoordinates);

    var routePath = new google.maps.Polyline({
        path:routeCoordinates,
        strokeColor:"#000000",
        strokeOpacity:.90,
        strokeWeight: 2,
        editable:false
    });
    console.log(routePath);

    routePath.setMap(map);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas">

</div>
</body>
</html>

Upvotes: 0

Views: 104

Answers (1)

geocodezip
geocodezip

Reputation: 161384

You map works for me if I remove the key and give the map div a size.

http://www.geocodezip.com/JohnSwaringenSO.html

Upvotes: 1

Related Questions