Phoca Maps 2.0.6: add Google Maps API KEY

As of June 2018 Google requires to always declare an API KEY when using Google Maps on your website (or app).

Phoca Maps 2.0.6, the last compatible version for Joomla 2.5, doesn’t support adding API KEY via configuration.
However it’s not very hard to manually change the source files to add this parameter.

On the website edit components/com_phocamaps/views/map/view.html and around line 89, where you find the following:

		$tmpl['params'] = '';
		if (!isset($item['map']->lang) || (isset($item['map']->lang) && $item['map']->lang == '')) {
			$tmpl['params'] 		= '{other_params:"sensor=false"}';
			$tmpl['paramssearch'] 	= '';
			$tmpl['lang']			= '';
		} else {
			//$tmpl['params'] = '{"language":"'.$item['map']->lang.'", "other_params":"sensor=false"}';
			$tmpl['params'] 		= '{other_params:"sensor=false&language='.$item['map']->lang.'"}';
			$tmpl['paramssearch'] 	= '{"language":"'.$item['map']->lang.'"}';
			$tmpl['lang']			= $item['map']->lang;
		}

change it to

		$tmpl['params'] = '';
		if (!isset($item['map']->lang) || (isset($item['map']->lang) && $item['map']->lang == '')) {
			$tmpl['params'] 		= '{other_params:"key=YOUR_API_KEY"}';
			$tmpl['paramssearch'] 	= '';
			$tmpl['lang']			= '';
		} else {
			//$tmpl['params'] = '{"language":"'.$item['map']->lang.'", "other_params:"key=YOUR_API_KEY"}}';
			$tmpl['params'] 		= '{other_params:"sensor=false&language='.$item['map']->lang.'"}';
			$tmpl['paramssearch'] 	= '{"language":"'.$item['map']->lang.'"}';
			$tmpl['lang']			= $item['map']->lang;
		}

The sensor o

Warning: this patch works only for normal map display on frontend and not for other features, nor for the backend. But you can easily search for sensor in the sources and apply the same change.

Header photo by Adolfo Félix on Unsplash

Lascia un commento

Il tuo indirizzo email non sarà pubblicato.

Solve : *
15 × 21 =


Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.