Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Putting values fom db in google js tpl

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
dloader
Smarty n00b


Joined: 19 Feb 2014
Posts: 1

PostPosted: Wed Feb 19, 2014 4:15 pm    Post subject: Putting values fom db in google js tpl Reply with quote

Hi there,
I'am absolutely new to smarty Smile and run into a problem with a project.
Iám building a joomla site with a component that's working with smarty
template.

The google map is a important part of the site, and when a user is logged in and opens the map i want the map to open and center based on the geolocation of the user.

The coordinates from every user is strored in the database i have captured that during the register proces.

The point is the map.tpl have include a javascript _maps_tpl i'am having problems to get the values in it i wrote to functions to retrieve the x and y coorinates.


public function getUserCoordinatesX()
{
$my = JFactory::getUser();
$db = JFactory::getDBO();
$queryx = "SELECT cb_googlex FROM #__comprofiler WHERE user_id =$my->id";
$db->setQuery($queryx);
$corResultx = $db->loadResult();
}
public function getUserCoordinatesY()
{
$my = JFactory::getUser();
$db = JFactory::getDBO();
$queryy = "SELECT cb_googley FROM #__comprofiler WHERE user_id =$my->id";
$db->setQuery($queryy);
$corResulty = $db->loadResult();

}


And this a part of the javascript.tpl

{import_js_file url="http://maps.googleapis.com/maps/api/js?key=`$cfg->google_key`&sensor=false"}
{* oms.min.js https://github.com/jawj/OverlappingMarkerSpiderfier *}
{import_js_file url="oms.min.js"}

{import_js_block}
var zoom = {$cfg->googlemap_default_zoom|default:"12"};
var oms;
var map;
var infoWindow;
var markersArray = [];


var gmap_width = {$cfg->googlemap_gx|default:250}
var gmap_height = {$cfg->googlemap_gy|default:80}

{if ($googleMapX && $googleMapY)}
var pointTox={$googleMap_X};
var pointToy={$googleMap_Y};
{else}
var pointTox={$cfg->googlemap_defx|default:52.13095909247831};
var pointToy={$cfg->googlemap_defy|default:5.0173187255859375};
{/if}

I have tried to pull the functions in but they give errors.
Anyone suggestions thanks in avanced.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP