find longitude / latitude button in listings

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

Moderator: alexandrleonenko

dubdubandaway
Newbie
Newbie
Posts: 3
Joined: Nov 25th, '20, 19:54

find longitude / latitude button in listings

Postby dubdubandaway » Nov 26th, '20, 11:06

whilst I am currently using Google Maps, when I click on the find longitude / Latitude button for a listing using an entered a valid address in the UK I get the following message

"Wrong parameters passed or incorrect address! Please try to write this address in a different format." I've tried entering a valid US address and the same message

I have an API key generated for the site and set up in the Mappings API tab under general settings so Maps Javascript API is enabled for the site

is there anything else I need to enable or is there a specific format required when entering an address to make the call work ?

Thanks in advance

administrator
Site Admin
Site Admin
Posts: 6176
Joined: Jan 7th, '09, 23:18
Contact:

Re: find longitude / latitude button in listings

Postby administrator » Nov 27th, '20, 09:22

Contact support and provide them access to your website to check what happens.

dubdubandaway
Newbie
Newbie
Posts: 3
Joined: Nov 25th, '20, 19:54

Re: find longitude / latitude button in listings

Postby dubdubandaway » Dec 2nd, '20, 19:37

further digging and checking has resolved the problem.

in the file
CGeoLocacation.php stored in the directory \framework\helpers\ the call to the google maps api is made using the command "file_get_contents()'

the server hosting company I use has disabled that functionality and superseded it with Curl

if you are having the same issue then try substituting the following lines over

In the function coordinatesByAddress

comment out the current code

Code: Select all

   [$json = file_get_contents($url);
                $json=readfile($url);
            $json = json_decode($json);

add in something along the lines of

Code: Select all

 $ch = curl_init();
         curl_setopt($ch, CURLOPT_TIMEOUT, 1);
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
            if(FALSE === ($retval = curl_exec($ch))) {
                   error_log(curl_error($ch));                 }
         $json = json_decode($retval);
         


no other changes are needed and the find location / latitude button should work for you.

if admin / support has time, they may even be able to code it so it chooses what code to run depending on the server set up.

administrator
Site Admin
Site Admin
Posts: 6176
Joined: Jan 7th, '09, 23:18
Contact:

Re: find longitude / latitude button in listings

Postby administrator » Dec 4th, '20, 08:22

In CHttpRequest method getUrlContent() have following parameters:

Code: Select all

function getUrlContent($url = '', $method = 'get', $data = [], $params = [], $function = 'file_get_contents')


by default this method called with 'curl'

Code: Select all

$json = A::app()->getRequest()->getUrlContent($url, 'get', [], [], 'curl');


so, you may define which option to use according to your needs.


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