go top

MEGA Sale

  • Colection of 65 PHP scripts for $4.29 each

Get 65 PHP scripts in a bundle for $4.29 each!

View Offer

Google Maps API update

by Dimitar Ivanov /  Useful Resources

Recently Google announced that they are changing the way their free Google Map service operates. The most important update related to how maps are loaded using JavaScript code in our scripts is the need to have an API key if you use Google Maps. They have also put a limit on a number of times maps and API calls can be loaded, so please read their blog and learn more "from the source".

Google Maps icon



BEFORE

Basically, until now maps were loaded using a simple JavaScript code. This is an example:

<script async defer src="https://maps.googleapis.com/maps/api/jscallback=initMap" type="text/javascript"></script>

 

NOW 

From now on they require maps to be loaded using your own API key. So,  the code above will look like this:

<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" type="text/javascript"></script>

 

All Google Maps JavaScript applications now require authentication using such API key. Read how to create a key for yourself. Please, make sure when you generate your key that it is for Google Map service.

Unfortunately, it is not possible for us, developers, to obtain a key which can be used in all our products. Instead, each client has to get such a key for every website where Google Map is used. Rather annoying for sure, but you must do it, otherwise Google Maps will not load.

We have a number of scripts that use Google Maps. Below you can find instructions for each one of them. In the upcoming weeks/months, we will launch an update for each product, so that such API key can be added directly via the script administration page. Until then, and for all older versions of our products, you have to update your files manually. 

 

Please, first create your API key for the website where you use our script!

 

Script Files to be updated
Car Rental Script app/controllers/pjFront.controller.php
app/controllers/pjAdminLocations.controller.php
Food Delivery Script app/controllers/pjAdminLocations.controller.php
app/controllers/pjApp.controller.php
app/web/js/pjFoodDelivery.js
Store Locator app/controllers/pjAdminStores.controller.php
app/controllers/pjFront.controller.php
Property Listing Script app/controllers/pjAdminProperties.controller.php
templates/default/js/pjListings.js
Travel Tours Script app/controllers/pjAdminListings.controller.php
Vacation Rental Script app/views/pjListings/elements/layout_1/includes/_map.php
app/views/pjListings/elements/layout_1/includes/viewgooglemap.php
app/views/pjListings/elements/layout_2/includes/_map.php
app/views/pjListings/elements/layout_2/includes/viewgooglemap.php

Version 3.3 and above
/app/controllers/pjAdminListings.controller.php
/app/plugins/pjDrawSearch/controllers/pjDrawSearch.controller.php
/app/plugins/pjDrawSearch/views/pjDrawSearch/pjActionControl.php
/templates/default/elements/map.php
Yellow Pages Script app/controllers/pjAdminListings.controller.php
app/controllers/pjListings.controller.php
templates/default/pjActionMap.php

 


Before editing the files, make a backup in case something goes wrong. Note that if you have a User Licence for the script, you will not be able to edit these files. You have two options:

  • If you've purchased your script within the last 12 months, we can make this update for you for FREE. Otherwise, a small charge will occur.
  • Upgrade to Developer Licence and try to do it yourself. Once you upgrade, you will be eligible for a 12-month support and we can then do it for you.

 

Open the files using Notepad or another plain text editor and search for this string:

"http://maps.googleapis.com/"

 

You will find this string in a number of places. You should add your API key in the URLs, so they look like this:

http://maps.googleapis.com/maps/api/?key=YOUR_API_KEY

http://maps.googleapis.com/maps/api/geocode/json?key=YOUR_API_KEY&address…

 

Let us know, if you have any questions!

Share on:

2 Comments to "Google Maps API update"

Kimberly Cole

Kimberly Cole / April 23, 2019 at 16:56 pm

Is this still relevant? My maps is not working and I have set up a Google API

Derek

Derek / November 27, 2016 at 12:35 pm

Many thanks for getting back so quickly Dimitar, especially on a weekend!
I have made the changes and the Map display is now fine. I still have a problem with the map polygon search which my debugger says "Cannot get geometry object from data you send to the GEOMETRY field"

[$query =coreframeworkpjMysqliDriver.class.php:16:string 'SELECT COUNT(*) AS `cnt`
FROM `vacationrentals_listings` AS t1
WHERE (t1.status = 'T' OR (t1.status = 'E' AND t1.expire >= CURDATE()))
AND t1.lat IS NOT NULL
AND t1.lng IS NOT NULL
AND GISWithin(Point(t1.lng, t1.lat), GeomFromText('Polygon((-2.3774413391947746 52.312060904216565, -4.596679620444775 52.02906374264843, -4.904296807944775 51.293070077254065, -3.4541014954447746 51.017440785337634,-2.3774413391947746 52.312060904216565))'))
LIMIT 1']

I will try and find the solution myself but if you can shed any light on the problem then that would be fantastic.

Thanks so much for your help.
Regards,
Derek Williams

Sasho Valkanov

Sasho Valkanov / November 29, 2016 at 07:35 am

Derek, it's possible that there are NULL values for the lat and lng fields for some of the properties.

Add your comment

Captcha

    Please, be polite and helpful and do not spam or offend others! We promise you will be treated the same way!

    Log in to your account to post your comments. If you still haven't joined our community yet, you can create your FREE account now!

    Posting tip:
    If you use code in your comments, please put it in these tags [php], [sql], [css], [js] PHP code example: [php] echo date("Y-m-d"); [/php]

    Thank you,
    PHPJabbers Team