Jump to content

google maps help


andyd34

Recommended Posts

I am trying to implement a visitors map with google maps but i'm not getting anywhere.

I am trying to to a marker on a map where every visitor came from.

Here is was i have.

 

<? 
include('settings/global.php'); 
$sqlC = mysql_query("SELECT * FROM postcodes WHERE Pcode = 'WA8'");
$rowC = mysql_fetch_assoc($sqlC);
$getPsql = mysql_query("SELECT * FROM Details");
while($row=mysql_fetch_assoc($getPsql)) {
if($row['Usr_Pcode']!='') {
$code = strtoupper($row['Usr_Pcode']);
$gtSQL = mysql_query("SELECT Latitude, Longitude FROM postcodes WHERE Pcode = '$code'");
$i = 1;
while($rowV=mysql_fetch_array($gtSQL)) {
	$lon[] = $rowV[0];
	$lat[] = $rowV[1];
	$count[] = $i;
	$i++;
}
}
}
?>

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script src="http://maps.google.com/maps?file=api&v=2&key=1234567890&sensor=false" type="text/javascript"></script>
<script type="text/javascript"> 
function initialize() {
  var map = new GMap2(document.getElementById("map_canvas"));
  map.setCenter(new GLatLng(<?=$rowC['Latitude']?>, <?=$rowC['Longitude']?>), 7);
  map.setMapType(G_SATELLITE_MAP);
  // Add 10 markers to the map at random locations
  var bounds = map.getBounds();
  var southWest = bounds.getSouthWest();
  var northEast = bounds.getNorthEast();
  var lngSpan = northEast.lng() - southWest.lng();
  var latSpan = northEast.lat() - southWest.lat();
  for (var i = 0; i < 10; i++) {
    var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
        southWest.lng() + lngSpan * Math.random());
    map.addOverlay(new GMarker(point));
  }
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 800px; height: 600px"></div>


</body>
</html>

 

I can get the map showing but when I try to add markers I get a blank page. I have tried several things includubg

 

<?
for($i=1 ; $ $i  <= count($count) ; $i++) {
?>
var point = new GLatLng(<?=$lat[$i]?>, <?=$lon[$i]?>), 
    map.addOverlay(new GMarker(point));
<?
}
?>

 

Instead of

 

  for (var i = 0; i < 10; i++) {
    var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
        southWest.lng() + lngSpan * Math.random());
    map.addOverlay(new GMarker(point));
  }

 

I have very little knowledge of javascript and all the tutorials are going right over my head. Cam someone please help!!

Link to comment
https://forums.phpfreaks.com/topic/162610-google-maps-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.