Google Maps Api - Map Not Showing - No Errors
I am trying to load a map from the Google API into a div. However, the map is not loaded, and no errors are outputted. This is the code: // google maps var geocoder, map; function
Solution 1:
The problem was:
- I didn't use API-key (even though it don't think this was nessecary, but it worked)
I didn't set the width/height of my div (
.map_canvas {width: 500px; height: 500px;}
).I forgot to initalize like so:
initialize(); functioninitialize() { google.maps.event.addDomListener(window, 'load', function() { codeAddress('London'); }); }
It now works. Thanks!
Solution 2:
Are you loading the Google Maps API...? Are not you missing something like this on your page?
<scripttype="text/javascript"src="https://maps.googleapis.com/maps/api/js?key=<your_api_key&sensor=false&callback=initialize"></script>
...
<script>functioninitialize() {
codeAddress('" . $location['address'] . " " . $location['zip'] . " " . $location['city'] . " " . $countries[$location['country']] . "');
});
</script>
Please take a look at Google's example.
Solution 3:
I assume you load the map on 'map_canvas' div, right? Try to define the height and the width of those div on your stylesheet, that's what happen to me on my project and it's solved for me... The problem seems to happen because of other style attributes like position or float maybe.
Post a Comment for "Google Maps Api - Map Not Showing - No Errors"