HOW TO make Google Map is working on uBusinessDirectory?

Discuss everything related to Business Directory. All versions. Any questions related to the Business Directory developing or using should be posted to this forum.

Moderators: ne_moj, zewa

HOW TO make Google Map is working on uBusinessDirectory?

Postby ne_moj on 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:
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>
User avatar
ne_moj
Master
Master
 
Posts: 240
Joined: Jan 1st, '16, 14:11

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

Postby chirng on Aug 1st, '16, 07:59

May I know how to set the default google map to a certain area other than New York city?
chirng
Master
Master
 
Posts: 144
Joined: Jun 7th, '09, 04:15

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

Postby ne_moj on Aug 1st, '16, 08:30

Hello

If I understand you correctly, you need to replace the 2 images "bd1.png" and "bd2.png" in directory "templates/default/img/photo".
User avatar
ne_moj
Master
Master
 
Posts: 240
Joined: Jan 1st, '16, 14:11

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

Postby chirng on Aug 2nd, '16, 03:31

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>
chirng
Master
Master
 
Posts: 144
Joined: Jun 7th, '09, 04:15

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

Postby ne_moj on Aug 2nd, '16, 07:10

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>
User avatar
ne_moj
Master
Master
 
Posts: 240
Joined: Jan 1st, '16, 14:11

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

Postby chirng on Dec 19th, '16, 05:29

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?
chirng
Master
Master
 
Posts: 144
Joined: Jun 7th, '09, 04:15

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

Postby ne_moj on Dec 19th, '16, 10:20

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
User avatar
ne_moj
Master
Master
 
Posts: 240
Joined: Jan 1st, '16, 14:11

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

Postby chirng on Dec 20th, '16, 04:01

how do we resolve this issue?

The key "target-densitydpi" is not supported. under ../templates/default/js/main.js
chirng
Master
Master
 
Posts: 144
Joined: Jun 7th, '09, 04:15

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

Postby ne_moj on Dec 21st, '16, 12:19

I answered a PM
User avatar
ne_moj
Master
Master
 
Posts: 240
Joined: Jan 1st, '16, 14:11


Return to ApPHP Business Directory / uBusinessDirectory Talk {developers/users}

Who is online

Users browsing this forum: No registered users and 1 guest