Reputation: 31
I need to implement on my php page map. I have container <div id="map"></div>
which is inside other div, and I put this code inside <head>
tag but it doesn't show at all. Can anybody help me?
<script type="text/javascript" src="javascript/jquery-1.4.3.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
(function() {
window.onload = function() {
var mapDiv = document.getElementById('map');
var latlng = new google.maps.LatLng(37.09, -95.71);
var options = {
center: latlng,
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(mapDiv, options);
}
})();
</script>
Upvotes: 3
Views: 4803
Reputation: 1
If any one using google map code from javascript or jquery or any language, He/She should use for local host https://localhost/test/ or in server https://example.com.
Means use secure url like https
Upvotes: 0
Reputation: 649
I had some thing like that happen and all I had to do was use jquery compliance code. jQuery(document).ready(function($) { $(function() { // Your map code here. }); });
Upvotes: 4
Reputation: 165
Your code does work for me even though the last line, when you close that anonymous function, gave me an error like you were using some illegal character, so I had to retype it. Once I did, it worked perfectly showing a road map of all of the United States. Other than that possible illegal character you could also try:
Hope that helps.
Upvotes: 1
Reputation: 13649
Did you specify size for your div? eg:
<div id="map" style="width: 300px; height: 300px;"></div>
If this doesn't work you might have to post a snippet of your HTML and CSS..
Upvotes: 12
Reputation: 12870
Check the validity of your HTML and the doctype declaration. It has been an issue on several Google Maps I've setup.
See this
Upvotes: 0