I am trying to make a module for joomla that makes a map using the google maps API.
The map itself works fine if the data is hardcoded in the javascript file, but I want to be able to use it easily on multiple sites, so setting all the options from the joomla backend would be preferable. I've been trying to do this with a JSON call, but it returns an error 500 when the page loads. My dev site is: http://dev.xander.dk.web1.symatic.dk/
The relevant code is as follows:
mod_google_maps.php (making the variables and connecting them to the fields in mod_google_maps.xml)
<?php
/**
* Hello World! Module Entry Point
*
* @package Joomla.Tutorials
* @subpackage Modules
* @link http://docs.joomla.org/J3.x:Creating_a_simple_module/Developing_a_Basic_Module
* @license GNU/GPL, see LICENSE.php
* mod_helloworld is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
// no direct access
defined('_JEXEC') or die;
// Include the syndicate functions only once
require_once( dirname(__FILE__) . '/helper.php' );
$mapCenterLat = $params->get('mapCenterLat', '55.395239');
$mapCenterLng = $params->get('mapCenterLng', '10.380180');
$zoom = $params->get('zoom', '18');
$mapDisableUi = $params->get('mapDisableUi', false);
$markerLat = $params->get('markerLat', '55.395239');
$markerLng = $params->get('markerLng', '10.380180');
$markerTitle = $params->get('markerTitle', 'symatic');
helper.php
<?php
function getMapOptionsAjax(){
$data = array('mapCenterLat' => $mapCenterLat, 'mapCenterLng' => $mapCenterLng, 'zoom' => $zoom, 'mapDisableUi' => $mapDisableUi, 'markerLat' => $markerLat, 'markerLng' => $markerLng, 'markerTitle' => $markerTitle );
echo json_encode($data);
};
?>
maps.js (only the relevant JSON call)
jQuery.get('index.php?option=com_ajax&module=google_maps&method=getMapOptions&format=json', function(data){
var mapResponse = data;
console.log(mapResponse);
});
I have left out the rest of the maps.js file as it is not relevant to this question, and because it works with hardcoded values.