Reputation: 12836
I have not seen this before usually a map either loads or it doesnt because of some error. I am getting the map to load without errors but it is blank:
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false&ver=3.0'></script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(43.9869349, -102.24306);
var myOptions = {
zoom: 6,
center: latlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
</script>
<div id="map_canvas" style="width:100%; height:300px"></div>
Anyone else seen this or know what might be the culprit? The map itself is sitting in a div that I am show/hide with jQuery. Could that be the conflict?
This was just a stupid conflict with the parent div where I had img {display:none} defined. Oops. .thanks everyone for trying to help.
Upvotes: 4
Views: 7537
Reputation: 21630
I tried google's example, which looks quite similar to what you're doing, and it worked fine.
http://code.google.com/apis/maps/documentation/javascript/examples/map-simple.html
I suspected that you had the lat/lng reversed, but that doesn't appear to be the case. Perhaps work through this example again - as I just ran it locally with no trouble.
Upvotes: 1
Reputation: 1097
Try this
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false&ver=3.0'></script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(43.9869349, -102.24306);
var myOptions = {
zoom: 6,
center: latlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
</script>
<div id="map_canvas" style="width:100%; height:300px"></div>
<script>initialize();</script>
Upvotes: 1
Reputation: 1377
try adding this:
window.onload = function(evt) {
// this is a simple replica of jQuery's ready function
if(document.readyState === 'complete') {
var latlng = new google.maps.LatLng(43.9869349, -102.24306);
var myOptions = {
zoom: 6,
center: latlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
}
Upvotes: 1