More questions...Google maps
Ok I have been searching far and wide for a simple solution, but no luck as yet.
I am looking for a simple way to integrate a google map using the postcode from a listing. I have seen one google maps module but that seems to have little support and the other one by Larry looks great but not really what I need as it is only required for one section and map generated from a postcode entered in the extra fields.
I just need to integrate a google map from the input post code in the listing using the proper API, I have looked really hard for a solution but the best I have done is:
<iframe width="WIDTH" height="HEIGHT" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.uk/maps?f=q&source=s_q&hl=en&geocode=& ;q={get_extra_field id=$view fid=11}&ie=UTF8&output=embed"></iframe>
By putting this into the template (where fid=11 is the postcode) I can display an embedded map from google but it is not 100% accurate and users can click away from the listing.
I think a better solution would be to use the API but that uses javascript and it causes problems in SMARTY.
Is there any simple way to generate an API map?
Can we somehow integrate the normal javascript google map easily from the API key?
I have found this but cannot get it to work:
<?php
require('Smarty.class.php');
require('GoogleMapAPI.class.php');
$smarty = new Smarty();
$map = new GoogleMapAPI();
// setup database for geocode caching
$map->setDSN('mysql://USER:PASS@localhost/GEOCODES');
// enter YOUR Google Map Key
$map->setAPIKey('YOURGOOGLEMAPKEY');
// create some map markers
$map->addMarkerByAddress('621 N 48th St # 6 Lincoln NE 68502','PJ Pizza','<b>PJ Pizza</b>');
$map->addMarkerByAddress('826 P St Lincoln NE 68502','Old Chicago','<b>Old Chicago</b>');
$map->addMarkerByAddress('3457 Holdrege St Lincoln NE 68502',"Valentino's","<b>Valentino's</b>");
// assign Smarty variables;
$smarty->assign('google_map_header',$map->getHeaderJS());
$smarty->assign('google_map_js',$map->getMapJS());
$smarty->assign('google_map_sidebar',$map->getSidebar());
$smarty->assign('google_map',$map->getMap());
// display the template
$smarty->display('index.tpl');
?>
contents of index.tpl:
----------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
{$google_map_header}
{$google_map_js}
<!-- necessary for google maps polyline drawing in IE -->
<style type="text/css">
v\:* {ldelim}
behavior:url(#default#VML);
{rdelim}
</style>
</head>
<body onload="onLoad()">
<table>
<tr>
<td>{$google_map}</td>
<td>{$google_map_sidebar}</td>
</tr>
</table>
</body>
</html>
Thanks everyone!!
Last edited by ThinkBusiness; 05-10-2010 at 03:21 PM.
|