Hola vb2005, y gracias por responder porque creo que esto lo tendría que haber puesto en el foro de PHP.
El tema es que se trata de un Joomla! con una extensión que incorpora la llamada a la API, que la incluye, parece ser con este php:
Código:
<?php
defined('_JEXEC') or die;
class SiteGoogleMaps
{
protected $jsApiKey;
protected $serverApiKey;
public function __construct($jsApiKey, $serverApiKey)
{
$this->jsApiKey = $jsApiKey;
$this->serverApiKey = $serverApiKey;
}
public static function getInstance($jsApiKey, $serverApiKey)
{
static $instance = null;
if (is_null($instance)) {
$instance = new self($jsApiKey, $serverApiKey);
}
return $instance;
}
public function getJsApiKey()
{
return $this->jsApiKey;
}
public function getServerApiKey()
{
return $this->serverApiKey;
}
public function geoCode($address)
{
jimport('joomla.filesyste.file');
$address = urlencode($address);
$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $address . '&key=' . $this->getServerApiKey();
$data = json_decode($this->getUrl($url));
\Joomla\CMS\Log\Log::add(
sprintf('Decoding address "%s", using api key "%s" and geocoding url: "%s"', urldecode($address), $this->getServerApiKey(), $url),
\Joomla\CMS\Log\Log::INFO,
'com_site.google_maps.geocoding'
);
if ('OK' != $data->status || !isset($data->results[0]->geometry->location)) {
\Joomla\CMS\Log\Log::add(
sprintf('Decoding address "%s" failed with error "%s"', urldecode($address), $data->error_message),
\Joomla\CMS\Log\Log::ERROR,
'com_site.google_maps.geocoding'
);
return false;
}
$location = $data->results[0]->geometry->location;
\Joomla\CMS\Log\Log::add(
sprintf('Decoded address "%s" to latitude "%s" and longitude "%s"', urldecode($address), $location->lat, $location->lng),
\Joomla\CMS\Log\Log::NOTICE,
'com_site.google_maps.geocoding'
);
return $location;
}
public function renderMap($id = 'site-googlemap', $location = array(), $height = '400', $width = '100%', $config = array())
{
// Render Javascript.
FactoryHtml::script('googlemaps');
JHtml::script('https://maps.googleapis.com/maps/api/js?key=' . $this->getJsApiKey());
JText::script('JPREVIOUS');
JText::script('JNEXT');
// Set default values for location.
if (!is_array($location)) {
$location = array();
}
if (!isset($location['lat']) || !isset($location['lng'])) {
$location['lat'] = 48;
$location['lng'] = 14;
}
if (!isset($location['zoom'])) {
$location['zoom'] = 3;
}
// Set default values for dimension.
if (false === strpos($height, '%')) {
$height .= 'px';
}
if (false === strpos($width, '%')) {
$width .= 'px';
}
$optionUseSimpleMarker = isset($config['useSimpleMarkers']) ? $config['useSimpleMarkers'] : 'false';
$options = '{ center: new google.maps.LatLng(' . $location['lat'] . ', ' . $location['lng'] . '), zoom: ' . $location['zoom'] . ', useSimpleMarkers: ' . $optionUseSimpleMarker . ' }';
if ($optionUseSimpleMarker) {
JHtml::script('components/com_site/assets/js/oms.min.js');
}
$document = JFactory::getDocument();
$initJs = '$("#' . $id . '").siteGoogleMap(' . $options . ') ';
$js = array();
$js[] = 'jQuery(document).ready(function ($) { ';
if (isset($config['initOnTabOpen'])) {
$tab = $config['initOnTabOpen'];
$js[] = 'var tab = $(".nav li a[href=\"#' . $tab . '\"]");';
$js[] = 'if (tab.parent().hasClass("active")) {';
$js[] = $initJs;
$js[] = '}';
$js[] = 'else {';
$js[] = ' $(".nav li a[href=\"#' . $tab . '\"]").click(function (event) { ';
$js[] = $initJs;
$js[] = ' });';
$js[] = '}';
} else {
$js[] = $initJs;
}
$js[] = ' });';
$document->addScriptDeclaration(implode("\n", $js));
$html = array();
$html[] = '<div id="' . $id . '" style="height: ' . $height . '; width: ' . $width . ';" class="site-google-map"></div>';
return implode("\n", $html);
}
public function renderJavascript()
{
FactoryHtml::script('googlemaps');
JHtml::script('https://maps.googleapis.com/maps/api/js?key=' . $this->getJsApiKey());
}
protected function getUrl($url)
{
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
if (!curl_errno($ch)) {
curl_close($ch);
return $output;
}
curl_close($ch);
}
return file_get_contents($url);
}
}
No sé si con modificar este archivo es suficiente o me voy a tener que meter en una reconstrucción completa de la extensión para poder actualizar.
Se trata del problema que surgió al hacerse obligatorio el callback para cargar la API. Podéis verlo aquí:
https://stackoverflow.com/questions/...ck-is-not-supp
Por supuesto, el desarrollador de la extensión desapareció sin dejar ni rastro y no hay forma de pedir soporte.