
RapidWeb
User
Jan 1, 2012, 2:35 PM
Post #1 of 11
(1305 views)
Shortcut
|
|
Geocoder: No map available!
|
Can't Post
|
|
Hi, I just ordered and installed the Geocoder plugin. Installation was a breeze. I used the code for a single map on my page and get and error message: “No Map Available”. This is my test page: http://www.koshertravelinfo.com/kosher-hotels/kosher-hotel.php?2 It does work in the sample page here: http://www.koshertravelinfo.com/cmsAdmin/plugins/geocoder/examples/sample_map_single.php My question is what did I do wrong? Do I have to add any code to the head? Any code to the body? My table name is “hotels”. This is my code in the header:
<?php /* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */ // load viewer library $libraryPath = 'cmsAdmin/lib/viewer_functions.php'; $dirsToCheck = array('//','','../','../../','../../../'); foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }} if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); } // load records list($hotelsRecords, $hotelsMetaData) = getRecords(array( 'tableName' => 'hotels', 'where' => whereRecordNumberInUrl(1), 'limit' => '1', )); $hotelsRecord = @$hotelsRecords[0]; // get first record // show error message if no matching record is found if (!$hotelsRecord) { dieWith404("Record not found!"); } ?> <script type="text/javascript" src="../js/prototype.js"></script> <script type="text/javascript" src="../js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="../js/lightbox.js"></script> <link rel="stylesheet" href="../css/lightbox.css" type="text/css" media="screen" /> <!-- 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 = <?php echo floatval(@$record['latitude']); ?>; var longitude = <?php echo floatval(@$record['longitude']); ?>; 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 --> This is my code inside the page:
<?php if (@$record['latitude']): ?> <div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 15px;"></div> <?php endif ?> <?php if (!@$record['latitude']): ?> <div style="width: 299px; height: 299px; float: left; margin: 0px 15px; border: 1px solid #000;"> <div style="text-align: center; padding-top: 135px"> No map available! </div> </div> <?php endif ?>
(This post was edited by RapidWeb on Jan 2, 2012, 8:26 AM)
|