HOW TO make Google Map is working on uBusinessDirectory?
Posted: Jul 1st, '16, 20:30
As per Google recent announcement, usage of the Google Maps APIs now requires a key. If you are using the Google Maps API on localhost or your domain was not active prior to June 22nd, 2016, it will require a key going forward.
Fix it as follows:
1) Getting an API key. How to do this can be seen here - https://www.latecnosfera.com/2016/06/go ... olved.html
2) Then add the following line to the file /protected/modules/directory/config/main.php:
Сontents of the file should look something like this:
3) And the last. It is necessary to make the following changes to the file templates/default/default.php:
- in the third line after the "<?php" add the following code:
Together with the rest of the code it's should look something like this:
- In this file, replace the line:
On this line:
Fix it as follows:
1) Getting an API key. How to do this can be seen here - https://www.latecnosfera.com/2016/06/go ... olved.html
2) Then add the following line to the file /protected/modules/directory/config/main.php:
Code: Select all
'googleApiKey' => 'YOUR_API_KEY',
Сontents of the file should look something like this:
Code: Select all
<?php
return array(
// module classes
'classes' => array(
'DirectoryComponent',
'Categories',
'CustomerGroups',
'Customers',
'Inquiries',
'Listings',
'ListingsCategories',
'Regions',
'Reviews',
'Orders',
'Plans',
'Home',
'SiteInfoFrontend',
'SocialNetworks',
'SocialNetworksLogin',
'AjaxHandler',
),
// management links
'managementLinks' => array(
A::t('directory', 'Site Info') => 'siteInfoFrontend/siteinfo',
A::t('directory', 'Categories') => 'categories/manage',
A::t('directory', 'Locations') => 'regions/manage',
A::t('directory', 'Listings') => 'listings/manage',
A::t('directory', 'Accounts') => 'customers/manage',
A::t('directory', 'Reviews') => 'reviews/manage',
A::t('directory', 'Inquiries') => 'inquiries/manage',
A::t('directory', 'Advertise Plans') => 'plans/manage',
A::t('directory', 'Orders') => 'orders/manage',
),
'googleApiKey' => 'BIzaSyBkg1RmDan8ko8Qe8W26nBcOjO83yw2wDQ',
);
3) And the last. It is necessary to make the following changes to the file templates/default/default.php:
- in the third line after the "<?php" add the following code:
Code: Select all
$configModule = CLoader::config('directory', 'main');
$googleApiKey = (isset($configModule['googleApiKey'])) ? $configModule['googleApiKey'] : '';
Together with the rest of the code it's should look something like this:
Code: Select all
<?php header('content-type: text/html; charset=utf-8'); ?>
<?php
$configModule = CLoader::config('directory', 'main');
$googleApiKey = (isset($configModule['googleApiKey'])) ? $configModule['googleApiKey'] : '';
if(Modules::model()->exists("code = 'directory' AND is_installed = 1")){
$socialNetworks = SocialNetworks::model()->findAll('site_id = :site_id AND is_published = 1', array(':site_id'=>1));
......
- In this file, replace the line:
Code: Select all
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false&language=en&ver=3.8.3'></script>
On this line:
Code: Select all
<script type='text/javascript' src='//maps.google.com/maps/api/js?sensor=false&language=en&ver=3.8.3&key=<?php echo $googleApiKey; ?>'></script>