Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Geocode on multi viewer

 

 


zick
User

Feb 20, 2011, 10:00 PM

Post #1 of 8 (4066 views)
Shortcut
Geocode on multi viewer Can't Post

Is it possible to get the geocode add-on to work on a multi viewer page. Example: I need to create a multi listing page of property listings and each property will need it's very own map display on the listing page, next to the property description. The multi page will displays 5 properties per page, where the site visitor would then click next to see the following 5 properties - each with it's very own map.

Thanks for any help,
Zick


(This post was edited by zick on Feb 20, 2011, 10:15 PM)


Jason
Staff / Moderator


Feb 21, 2011, 10:40 AM

Post #2 of 8 (4033 views)
Shortcut
Re: [zick] Geocode on multi viewer [In reply to] Can't Post

Hi Zick,

Yes, this is possible, but if you're producing one separate map using javascript for each record, it can start to get really slow. A quick work around that would be quicker would be to use an iframe for each record that embeds a google map. You can do this with the latitude and longitude fields created by the plugin. Here's an example of what it would look like:


Code
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?ll=<?php echo $record['latitude'];?>,<?php echo $record['longitude'];?>;output=embed"></iframe><br />


Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


zick
User

Feb 21, 2011, 11:35 AM

Post #3 of 8 (4030 views)
Shortcut
Re: [Jason] Geocode on multi viewer [In reply to] Can't Post

Hey Jason,
I plugged in the code you provided, but it's returning a generic Google map search page inside the iframe. Do you know if I need to apply for a google API key to get this working?

As an alternative, could you explain what I'd need to do if I where to use the javascript to generate the maps.

Here's the code I'm using:


Code
 ///////////////////////////////////// geo records ///////////////////////////////////// 
list($myRecords, $myMetaData) = getRecords(array(
'tableName' => 'properties',
//'tableName' => $GLOBALS['GEOCODER_SAMPLE_TABLENAME'],
//'where' => whereRecordNumberInUrl(1),
//'limit' => '1',
));
$record = @$myRecords[0]; // get first record
///////////////////////////////////// end geo records /////////////////////////////////////

// load records
list($propertiesRecords, $propertiesMetaData) = getRecords(array(
'tableName' => 'properties',
'perPage' => '3',
//'allowSearch' => false,
));

$propertiesRecord = @$propertiesRecords[0]; // get first record



<!-- geomap -->
<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>
<!-- /geomap -->




<!-- geomap -->
<?php if (@$record['latitude']): ?>
<br />
<div id="map_canvas" style="width: 400px; height: 240px; float: left; margin: 0px 0px; border: 1px solid #CCC;"></div>
<?php endif ?>

<?php if (!@$record['latitude']): ?>
<?php /*?>show nothing<?php */?>
<?php endif ?>

<!-- /geomap -->



Jason
Staff / Moderator


Feb 22, 2011, 10:47 AM

Post #4 of 8 (3940 views)
Shortcut
Re: [zick] Geocode on multi viewer [In reply to] Can't Post

Hi Zick,

You shouldn't need an API key. Could you show me a url where you tried this so I can take a look?

To use the javascript from the example code, you'd need to put the javascript that produces a single map in a foreach loop that would output that block of code for each record you returned.

You'd also need to make sure that you where giving each map a unique id.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


Toledoh
Enthusiast

Feb 22, 2011, 3:56 PM

Post #5 of 8 (3933 views)
Shortcut
Re: [zick] Geocode on multi viewer [In reply to] Can't Post

Hey Zick.

Not sure if this helps (my brain's going a bit slow today) but have a look at http://www.ragatzdeanconsulting.com/index2.php

This is using a jQuery plugin, and the Geo plugin and works a treat. More about that here http://www.interactivetools.com/iforum/gforum.cgi?post=84402
Cheers,

Tim Forrest
Toledoh Enterprises
www.toledoh.com.au


equinox69
User

May 28, 2011, 4:52 AM

Post #6 of 8 (3222 views)
Shortcut
Re: [Jason] Geocode on multi viewer [In reply to] Can't Post

Hi Jason,
I am using the geocoder on a page that will have other javascript that interrupts the geocoder-generated google map code:

Code
<!-- STEP3: Map with single address: Put this where you want your map displayed, rename $record if needed --> 


<?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 ?>
<!-- STEP3: /Map with single address -->


How would I embed this in an iframe? The string you provided in this thread generates a generic google map of the west coast of the US.
Thanks!


Jason
Staff / Moderator


May 30, 2011, 9:39 AM

Post #7 of 8 (3162 views)
Shortcut
Re: [equinox69] Geocode on multi viewer [In reply to] Can't Post

Hi,

You can create a new .php page that only displays your map. Once you have that working the way you want to, you can include that page as an iframe in your main page.

Hope that helps get you started.
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


equinox69
User

May 30, 2011, 9:56 AM

Post #8 of 8 (3160 views)
Shortcut
Re: [Jason] Geocode on multi viewer [In reply to] Can't Post

That makes sense!...and I DO have it working on the separate page. Have a great holiday!