Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Geocoder: No map available!

 

 


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:


Code
<?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:


Code
  

<?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)


Jason
Staff / Moderator


Jan 2, 2012, 9:45 AM

Post #2 of 11 (1284 views)
Shortcut
Re: [RapidWeb] Geocoder: No map available! [In reply to] Can't Post

Hi,

The message "No Map Available" is being displayed because there is no value in the latitude field of that record. This usually happens when a section has not yet been geocoded. Go through the plugin screen to geocode your hotels section and then try loading the page again.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


RapidWeb
User

Jan 2, 2012, 12:34 PM

Post #3 of 11 (1279 views)
Shortcut
Re: [Jason] Geocoder: No map available! [In reply to] Can't Post

Thanks for your quick reply.

Both fields are populated (latitude and longitude). This section (hotels) has only 3 listings now. It is still in testing mode before we change over the entire site. The first thing I did was run the plugin “Geocode Talbes” for the new Hotels section. Yet still, I get the No map available message.

I added these two fields to the page so that you can see that the fields are populated even on the published page:

latitude: <?php echo $hotelsRecord['latitude'] ?><br/>

longitude: <?php echo $hotelsRecord['longitude'] ?><br/>

This is the page:

http://www.koshertravelinfo.com/kosher-hotels/kosher-hotel.php?3

I do see in the source code for the published page that there is no information for latitude and longitude in the script:

function initialize() {

var latitude = 0;

var longitude = 0;



For some reason it does not get the info…


(This post was edited by RapidWeb on Jan 2, 2012, 1:43 PM)


Jason
Staff / Moderator


Jan 2, 2012, 1:40 PM

Post #4 of 11 (1271 views)
Shortcut
Re: [RapidWeb] Geocoder: No map available! [In reply to] Can't Post

Hi,

It looks like the issue is that you use the variable $hotelRecord to store your individual hotel record, but you use the variable $record when dealing with the geocoder code.

Try replacing $record with $hotelRecord in your geocoder code. That should take care of the problem.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


RapidWeb
User

Jan 2, 2012, 2:05 PM

Post #5 of 11 (1270 views)
Shortcut
Re: [Jason] Geocoder: No map available! [In reply to] Can't Post

Still does not work… Please see my post before regarding that the latitude does show up on the page. I had edited my post right when you replied.

I changed $record to $hotelsRecord as instructed and still the Google map does not load.


(This post was edited by RapidWeb on Jan 2, 2012, 2:06 PM)


Jason
Staff / Moderator


Jan 2, 2012, 2:44 PM

Post #6 of 11 (1266 views)
Shortcut
Re: [RapidWeb] Geocoder: No map available! [In reply to] Can't Post

Hi,

Could you please attach the kosher-hotel.php so I can take a closer look at your code?

Thanks
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


RapidWeb
User

Jan 2, 2012, 2:48 PM

Post #7 of 11 (1265 views)
Shortcut
Re: [Jason] Geocoder: No map available! [In reply to] Can't Post

Here it is.

Thank you in advance for all your help!
Attachments: kosher-hotel.php (9.71 KB)


Jason
Staff / Moderator


Jan 2, 2012, 3:01 PM

Post #8 of 11 (1261 views)
Shortcut
Re: [RapidWeb] Geocoder: No map available! [In reply to] Can't Post

Hi,

You have an extra "$" in front of your variables.

Try changing this:


Code
  <?php if (@$$hotelsRecord['latitude']): ?> 
<div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 15px;"></div>
<?php endif ?>

<?php if (!@$$hotelsRecord['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 ?>


to this:


Code
  <?php if (@$hotelsRecord['latitude']): ?> 
<div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 15px;"></div>
<?php endif ?>

<?php if (!@$hotelsRecord['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 ?>


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


RapidWeb
User

Jan 2, 2012, 3:36 PM

Post #9 of 11 (1258 views)
Shortcut
Re: [Jason] Geocoder: No map available! [In reply to] Can't Post

I fixed this problem. Yet no map shows up. Only difference now is that nothing shows up where the map should be. Not even the message “No map available!”.

It is evident from the source code of the published page that at least now the page does get the latitude:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript">

function initialize() {

var latitude = 41.9044114;

var longitude = -72.6348236


Jason
Staff / Moderator


Jan 3, 2012, 8:08 AM

Post #10 of 11 (1243 views)
Shortcut
Re: [RapidWeb] Geocoder: No map available! [In reply to] Can't Post

Hi,

Please fill out a 2nd Level Support Request and I will take a closer look at the page for you.

Thanks
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


RapidWeb
User

Jan 3, 2012, 2:20 PM

Post #11 of 11 (1230 views)
Shortcut
Re: [Jason] Geocoder: No map available! [In reply to] Can't Post

Hey Jason,

Thank you so much for your help.

For the record, this is what was needed in the body tag:


Code
  

<body onload="initialize();">



I am just posting this here so that others and myself can reference back to this at a later time for other sites and sections.


(This post was edited by RapidWeb on Jan 5, 2012, 3:27 PM)