Geocoder - No map available (Please help)

By kovali - November 13, 2013 - edited: November 13, 2013

Hi, I'm really stuck with the Geocoder plugin, I can't seem to get it to work... I only get " No map available" on my site.

The latitude and longitude fields are populated ok I think.  Here is my code:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'beheer/lib/viewer_functions.php';
$dirsToCheck = array('/home/vdwproje/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// error checking
if (!@$GLOBALS['GEOCODER_PLUGIN']) { die("You must activate the Geocoder plugin before you can access this page."); }

// load records from 'projecten'
list($projectenRecords, $projectenMetaData) = getRecords(array(
'tableName' => 'projecten',
'loadUploads' => true,
'allowSearch' => false,
));

list($pandenRecords, $pandenMetaData) = getRecords(array(
'tableName' => 'panden',
'orderBy' => 'title ASC',
'where' => whereRecordNumberInUrl(1),
));
$pandenRecord = @$pandenRecords[0]; // get first record

?>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var latitude = <?php echo floatval(@$pandenRecord['latitude']); ?>;
var longitude = <?php echo floatval(@$pandenRecord['longitude']); ?>;
var mapCanvasId = 'map_canvas2';
if (latitude) {
var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions);
var latLng = new google.maps.LatLng(latitude, longitude);
var marker = new google.maps.Marker({map: map, position: latLng });

map.setCenter(latLng);
map.setZoom(14);
}
}
</script>

<body>

<body onload="initialize()">

<?php if (@$pandenrecord['latitude']): ?>
<div id="map_canvas2" style="width: 630px; height: 268px; float: left; margin: 0px 15px;"></div>
<?php endif ?>

<?php if (!@$pandenrecord['latitude']): ?>
<div style="width: 630px; height: 268px; float: left; margin: 0px 15px; border: 1px solid #000;">
<div style="text-align: center; padding-top: 135px">
No map available!
</div>
</div>
<?php endif ?>

Attachments:

pandendetail.php 24K

Geocoder - No map available

By kovali - November 13, 2013

In the html sourcecode I see the latitude , so why doesn't the map show ??

<!-- STEP1: Map with single address: Put this in the <head> of your page, rename $record if needed --> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript"> function initialize() { var latitude = 50.86982; var longitude = 4.68428; var mapCanvasId = 'map_canvas'; if (latitude) { var mapOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById(mapCanvasId), mapOptions); var latLng = new google.maps.LatLng(latitude, longitude); var marker = new google.maps.Marker({map: map, position: latLng });
map.setCenter(latLng); map.setZoom(14); } } </script> <!-- /STEP1: Map with single address -->