I'm trying to get this to work as well. I followed the instructions, setting up a latitude and longitude field in my real estate listings detail page, listingDetail.php, then output the code and copied the appropriate php in the appropriate place, but I can't get the page to work correctly, here's my entire page code:
<?php
require_once "/home/content/g/r/e/greenways1/html/cmsAdmin/lib/viewer_functions.php";
list($listingRecords, $listingMetaData) = getRecords(array(
'tableName' => 'listing',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$listingRecord = @$listingRecords[0]; // get first record
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAzWpdtAJy15_mFvJb9uOTTxSpUoc7Yr5GTKWfF5EG52h_OrBQ8BQO9BWmFxt8DPC9oYhAuCCswFK5YQ"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.778855861649966, -79.98664855957031), 13);
}
<?php foreach ($listingRecords as $record): ?>
var point = new GLatLng(<?php echo $listingRecord['latitude'] ?>,<?php echo $listingRecord['longitude'] ?>);
var marker = createMarker(point,'<?php echo htmlspecialchars($record['address'], ENT_QUOTES) ?>, <?php echo htmlspecialchars($record['city'], ENT_QUOTES) ?>')
map.addOverlay(marker);
<?php endforeach; ?>
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 200px; height: 200px"></div>
</body>
your code is <?php echo $record['latitude'] ?>, I changed that to <?php echo $listingRecord['latitude'] ?>? Is that right? I've tried changing different things in the code but nothing seems to work. Thanks for any help.
John
John C. Morris
Interdimensional Designs
www.covdesigns.com