Geocoder: No map available!

By (Deleted User) - January 1, 2012 - edited: January 2, 2012

[font "Calibri"]Hi,[/#000000]

[font "Calibri"]I just ordered and installed the Geocoder plugin. Installation was a breeze.[/#000000]

[font "Calibri"]I used the code for a single map on my page and get and error message:[/#000000]

[font "Calibri"]“No Map Available”.[/#000000]
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



[font "Calibri"]My question is what did I do wrong?[/#000000]

[font "Calibri"]Do I have to add any code to the head?[/#000000]

[font "Calibri"]Any code to the body?[/#000000]

[font "Calibri"]My table name is “hotels”.[/#000000]


This is my code in the header:

<?php


// 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:

[/#0000ff][/#0000ff]

<?[/#0000ff][/#0000ff]php[/#800000][/#800000] if[/#ff0000][/#ff0000] (@$record[/#ff0000][/#ff0000]['latitude'[/#0000ff][/#0000ff]]):[/#ff0000][/#ff0000] ?>[/#0000ff][/#0000ff]

<[/#0000ff][/#0000ff]div[/#800000][/#800000] id[/#ff0000][/#ff0000]="map_canvas"[/#0000ff][/#0000ff] style[/#ff0000][/#ff0000]="width: 299px; height: 299px; float: left; margin: 0px 15px;"></[/#0000ff][/#0000ff]div[/#800000][/#800000]>[/#0000ff][/#0000ff]

<?[/#0000ff][/#0000ff]php[/#800000][/#800000] endif[/#ff0000][/#ff0000] ?>[/#0000ff][/#0000ff]

<?[/#0000ff][/#0000ff]php[/#800000][/#800000] if[/#ff0000][/#ff0000] (!@$record[/#ff0000][/#ff0000]['latitude'[/#0000ff][/#0000ff]]):[/#ff0000][/#ff0000] ?>[/#0000ff][/#0000ff]

<[/#0000ff][/#0000ff]div[/#800000][/#800000] style[/#ff0000][/#ff0000]="width: 299px; height: 299px; float: left; margin: 0px 15px; border: 1px solid #000;">[/#0000ff][/#0000ff]

<[/#0000ff][/#0000ff]div[/#800000][/#800000] style[/#ff0000][/#ff0000]="text-align: center; padding-top: 135px">[/#0000ff][/#0000ff]

No map available!

</[/#0000ff][/#0000ff]div[/#800000][/#800000]>[/#0000ff][/#0000ff]

</[/#0000ff][/#0000ff]div[/#800000][/#800000]>[/#0000ff][/#0000ff]

<?[/#0000ff][/#0000ff]php[/#800000][/#800000] endif[/#ff0000][/#ff0000] ?>[/#0000ff][/#0000ff]

[/#0000ff][/#0000ff]

Re: [RapidWeb] Geocoder: No map available!

By Jason - January 2, 2012

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 - Project Manager
interactivetools.com

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

Re: [Jason] Geocoder: No map available!

By (Deleted User) - January 2, 2012 - edited: January 2, 2012

[font "Calibri"]Thanks for your quick reply.[/#000000]

[font "Calibri"]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.[/#000000]

[font "Calibri"]I added these two fields to the page so that you can see that the fields are populated even on the published page:[/#000000]

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

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

This is the page:

[url "http://www.koshertravelinfo.com/kosher-hotels/kosher-hotel.php?3"][font "Calibri"]http://www.koshertravelinfo.com/kosher-hotels/kosher-hotel.php?3[/#0000ff][/url]

[font "Calibri"]I do see in the source code for the published page that there is no information for latitude and longitude in the script:[/#000000]

[/#000000]function initialize() {[/#000000]

[/#000000]var latitude = 0;[/#000000]

[/#000000]var longitude = 0;[/#000000]

[/#000000]

For some reason it does not get the info…[/#000000]

Re: [RapidWeb] Geocoder: No map available!

By Jason - January 2, 2012

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 - Project Manager
interactivetools.com

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

Re: [Jason] Geocoder: No map available!

By (Deleted User) - January 2, 2012 - edited: January 2, 2012

[font "Calibri"]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.[/#000000]

[font "Calibri"]I changed $record to $hotelsRecord as instructed and still the Google map does not load.[/#000000]

Re: [Jason] Geocoder: No map available!

By (Deleted User) - January 2, 2012

Here it is.

Thank you in advance for all your help!
Attachments:

kosher-hotel.php 10K

Re: [RapidWeb] Geocoder: No map available!

By Jason - January 2, 2012

Hi,

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

Try changing this:

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

<?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 - Project Manager
interactivetools.com

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

Re: [Jason] Geocoder: No map available!

By (Deleted User) - January 2, 2012

[font "Calibri"]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!”.[/#000000]

[font "Calibri"]It is evident from the source code of the published page that at least now the page does get the latitude:[/#000000]

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

[/#000000]<script [/#000000]type="text/javascript">

[/#000000]function initialize() {[/#000000]

[/#000000]var latitude = 41.9044114;[/#000000]

[/#000000]var longitude = -72.6348236[/#000000]

Re: [RapidWeb] Geocoder: No map available!

By Jason - January 3, 2012

Hi,

Please fill out a [url http://www.interactivetools.com/support]2nd Level Support Request[/url] and I will take a closer look at the page for you.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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