Google map shows blank page

I went through numerous tutorials over last few days and I registered my site and got API but I am getting a blank page no matter what tutorial I try. However if I just try first example (very basic one from google) that works fine. Which means my API is good. please find my code below.

Thanks in advance
<html>
<head>
<title>Who locations in London</title>
<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&source=uds-msw&key=MY API KEY"
    type="text/javascript"></script>
</head>
<body>
<p><strong>Who-locations in London</strong></p>
<div id="map" style="width: 800px; height: 600px"></div> 
<script type="text/javascript">
//<![CDATA[
 
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(51.512161, -0.14110), 11, G_NORMAL_MAP);
 
// Creates a marker whose info window displays the given number
function createMarker(point, number)
{
var marker = new GMarker(point);
// Show this markers index in the info window when it is clicked
var html = number;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
};
 
<?php
$link = mysql_connect("localhost", "user", "pass") or die("Could not connect: " . mysql_error());
mysql_selectdb("[db_googlemap]",$link) or die ("Can\'t use dbmapserver : " . mysql_error());
 
$result = mysql_query("SELECT * FROM markers",$link);
if (!$result)
{
echo "no results ";
}
while($row = mysql_fetch_array($result))
{
echo "var point = new GLatLng(" . $row['lat'] . "," . $row['lon'] . ");\n";
echo "var marker = createMarker(point, '" . addslashes($row['address']) . "');\n";
echo "map.addOverlay(marker);\n";
echo "\n";
}
 
mysql_close($link);
?>
 
//]]>
</script>
 
</body>
</html>

Open in new window

LVL 9
syedasimmeesaqAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

david-navertechCommented:
This is may be a long shot, as I have limited knowledge of the Google Maps API.  I had had a similar problem recently which was due to the <body> onload event being missed out.

I noticed your code example doesn't have the Javascript in the <head> section.  Never seen it done this way, but you could try the amended code below and see if it makes any difference.
<html>
<head>
<title>Who locations in London</title>
<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&source=uds-msw&key=MY API KEY"
    type="text/javascript"></script>
 
<script type="text/javascript">
//<![CDATA[
     function load() {
      if (GBrowserIsCompatible()) {
 
	var map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GScaleControl());
	map.setCenter(new GLatLng(51.512161, -0.14110), 11, G_NORMAL_MAP);
 
	// Creates a marker whose info window displays the given number
	function createMarker(point, number)
	{
	var marker = new GMarker(point);
	// Show this markers index in the info window when it is clicked
	var html = number;
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
	return marker;
	};
 
	<?php
	$link = mysql_connect("localhost", "user", "pass") or die("Could not connect: " . mysql_error());
	mysql_selectdb("[db_googlemap]",$link) or die ("Can\'t use dbmapserver : " . mysql_error());
 
	$result = mysql_query("SELECT * FROM markers",$link);
	if (!$result)
	{
	echo "no results ";
	}
	while($row = mysql_fetch_array($result))
	{
	echo "var point = new GLatLng(" . $row['lat'] . "," . $row['lon'] . ");\n";
	echo "var marker = createMarker(point, '" . addslashes($row['address']) . "');\n";
	echo "map.addOverlay(marker);\n";
	echo "\n";
	}
 
	mysql_close($link);
	?>
 
       }
     }
 
//]]>
</script>
 
</head>
<body onload="load()" onunload="GUnload()">
<p><strong>Who-locations in London</strong></p>
<div id="map" style="width: 800px; height: 600px"></div>  
</body>
</html>

Open in new window

0
syedasimmeesaqAuthor Commented:
Thank you for your response. but it didn't work.
0
syedasimmeesaqAuthor Commented:
ok I got the map showing up using this code below. Now only the last thing I want is some how just show the drop down menu and the user select a city and it shows the mark for only that city.. right now its showing marks for every single thing in database.
Thanks

<html>
<head>
<title>Develop</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=A5QIAAAATjreLXgWDrRF8XPcGEMwjhShwzBVeT4JMjZcXWYv7cJRtxOejRRZ1OaoDadfEWRjjQMFEYVMtBnISA" type="text/javascript"></script>
</head>
<body>
<p><strong>Who-locations in London</strong></p>
<div id="map" style="width: 800px; height: 600px"></div> 
 
<script type="text/javascript">
//<![CDATA[
 
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GScaleControl());
map.setCenter(new GLatLng(39.577658, -104.988276), 11, G_NORMAL_MAP);
 
// Creates a marker whose info window displays the given number
function createMarker(point, number)
{
var marker = new GMarker(point);
// Show this markers index in the info window when it is clicked
var html = number;
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
return marker;
};
 
<?php
$link = mysql_connect("localhost", "user", "pass") or die("Could not connect: " . mysql_error());
mysql_selectdb("db",$link) or die ("Can\'t use dbmapserver : " . mysql_error());
 
$result = mysql_query("SELECT * FROM locations",$link);
if (!$result)
{
echo "no results ";
}
while($row = mysql_fetch_array($result))
{
echo "var point = new GLatLng(" . $row['lat'] . "," . $row['lng'] . ");\n";
echo "var marker = createMarker(point, '" . addslashes($row['name']) . "');\n";
echo "map.addOverlay(marker);\n";
echo "\n";
}
 
mysql_close($link);
?>
 
//]]>
</script>
 
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
syedasimmeesaqAuthor Commented:
why would this not work in query

$result = mysql_query("SELECT * FROM locations where city=London",$link);
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.