Geocoder: showing maps from more than one table

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 22, 2012   (RSS)

By hiroko - October 19, 2012

Hello,

Thank you for the website membership upload reply last month, I have not got it to work, but thought I would get done with the other parts first.
Now I am having trouble with the geocoder. Please help.

I am trying to show a single map on my detail page from several leftjoin fields.
I cannot figure out how to write in the <head> part. I have tried listing them with a comma and {}, but not working.

I want to show all the maps for :
gallery_list_a_i.gallery_a_i
gallery_list_j_r.gallery_j_r
gallery_list_s_z.gallery_s_z
gallery_list_123.gallery_123
museum_list_a_n.museum_a_n
museum_list_o_z.museum_o_z


here is my code at top
// load record from 'event'
list($eventRecords, $eventMetaData) = getRecords(array(
'tableName' => 'event',
'where' => 'event.num = ' . getNumberFromEndOfUrl(),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
'leftJoin' => array(
// foreign table => local field (that matches num in foreign table)
'gallery_list_a_i' => 'gallery_a_i',
'gallery_list_j_r' => 'gallery_j_r',
'gallery_list_s_z' => 'gallery_s_z',
'gallery_list_123' => 'gallery_123',
'museum_list_a_n' => 'museum_a_n',
'museum_list_o_z' => 'museum_o_z',
),
));
$eventRecord = @$eventRecords[0]; // get first record
if (!$eventRecord) { dieWith404("Record not found!"); } // show error message if no record found

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


and here for <head>.
(right now, this is working for this field but don't know how to work with more than one field.
<!-- 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(@$eventRecord['gallery_list_a_i.latitude']); ?>;
var longitude = <?php echo floatval(@$eventRecord['gallery_list_a_i.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 -->


in the body,
<div id="gallerymap">
<?php if (@$eventRecord['gallery_list_a_i.latitude']): ?>
<div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 0px;"></div>
<?php endif ?>
<?php if (@$eventRecord['gallery_list_j_r.latitude']): ?>
<div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 0px;"></div>
<?php endif ?>
<?php if (@$eventRecord['gallery_list_s_z.latitude']): ?>
<div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 0px;"></div>
<?php endif ?>
<?php if (@$eventRecord['gallery_list_123.latitude']): ?>
<div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 0px;"></div>
<?php endif ?>
<?php if (@$eventRecord['museum_list_a_n.latitude']): ?>
<div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 0px;"></div>
<?php endif ?>
<?php if (@$eventRecord['museum_list_o_z.latitude']): ?>
<div id="map_canvas" style="width: 299px; height: 299px; float: left; margin: 0px 0px;"></div>
<?php endif ?>
</div>

Re: [greg] Geocoder: showing maps from more than one table

By hiroko - October 22, 2012

Thank you so much for your help!!
It worked great!

hiroko