Page 1 of 2

HOW TO make Google Map is working on uBusinessDirectory?

Posted: Jul 1st, '16, 20:30
by ne_moj
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:

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&#038;language=en&#038;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>

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Aug 1st, '16, 07:59
by chirng
May I know how to set the default google map to a certain area other than New York city?

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Aug 1st, '16, 08:30
by ne_moj
Hello

If I understand you correctly, you need to replace the 2 images "bd1.png" and "bd2.png" in directory "templates/default/img/photo".

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Aug 2nd, '16, 03:31
by chirng
I try to replace it as below:

<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false&#038;language=en&#038;ver=3.8.3&key=<?php echo $googleApiKey; ?>'></script>

otherwise it will come out 1 more error as below: -

js?sensor=false&language=en&ver=3.8.3:31 Google Maps API error: MissingKeyMapError https://developers.google.com/maps/docu ... -map-error

but anyhow, I still can't resolve this error:-

Google Maps API warning: SensorNotRequired https://developers.google.com/maps/docu ... t-required

And not more error as I change it to:-

<script type='text/javascript' src='http://maps.google.com/maps/api/js?language=en&#038;ver=3.8.3&key=<?php echo $googleApiKey; ?>'></script>

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Aug 2nd, '16, 07:10
by ne_moj
Hello

For whatever reason, there is no parameter the key

Try replacing the line:
<script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false&#038;language=en&#038;ver=3.8.3&key=<?php echo $googleApiKey; ?>'></script>

On this line:
<script type='text/javascript' src='//maps.google.com/maps/api/js?sensor=false&language=en&ver=3.8.3&key=<?php echo $googleApiKey; ?>'></script>
Or on the:
<script type='text/javascript' src='//maps.google.com/maps/api/js?sensor=false&#038;language=en&#038;ver=3.8.3&#038;key=<?php echo $googleApiKey; ?>'></script>

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Dec 19th, '16, 05:29
by chirng
google map was working when i setup a site up in a few months ago, but then not working now, may I know how to debug on google map error?

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Dec 19th, '16, 10:20
by ne_moj
Hello

All the js errors (including errors with Google Maps) can be viewed in the debug mode (for desktop version) It is usually possible to cause the in browser by pressing f12 and go to the console tab

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Dec 20th, '16, 04:01
by chirng
how do we resolve this issue?

The key "target-densitydpi" is not supported. under ../templates/default/js/main.js

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Dec 21st, '16, 12:19
by ne_moj
I answered a PM

Re: HOW TO make Google Map is working on uBusinessDirectory?

Posted: Mar 29th, '18, 09:47
by Vlad
Hello.

I tried to change the map for my country, nothing happens, New York remains. I need help.
Thank you.