Fix to Vantage google-maps.php code
Numerous topics about why Vantage maps are not working:
http://forums.appthemes.com/help-usi...-google-90267/
http://forums.appthemes.com/help-usi...nt-work-93865/
http://forums.appthemes.com/help-usi...working-93933/
I had a look at my site to see if there was any problems.
The maps load up OK.
I then had a look at the "Firefox Firebug Console" and it was displaying the error:
HTML Code:
Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys
So I had a look at what URL was been generated by Vantage to load up the maps and it was:
HTML Code:
http://maps.google.com/maps/api/js?v=3&ver=3#038;sensor=false®ion=au&language=en&key=xxxxxxxxxxxxxxxxxx
Definitely the "key=xxxxxxxxx" is been provided in the URL (xxxx - blanked out) as to what I had entered in the "Vantage->Geo Services->Map - Google TAB->API Key", so this part is working ok.
But it appears Google is not receiving the KEY.
I then logged into "Google API Manager" and looked at the "Google Maps JavaScript API" Usage page to see what activity there was and it showed
NO Activity.
It turns out that the Vantage generated URL is NOT working correctly and the problem is due to the "ver=3#038;" been added to the URL, that is the "#038;" is been added instead of "&".
The "#038;" is been added by the wordpress function wp_enqueue_script.
I then altered the "vantage\includes\geo\map-providers\google-maps.php" code so that the "ver=3#038;" is not added to the URL:
From:
PHP Code:
wp_enqueue_script( 'google-maps-api', $google_maps_url, array(), '3', true );
To:
PHP Code:
wp_enqueue_script( 'google-maps-api', $google_maps_url, array(), null, true );
After this change the maps worked and the Vantage generated URL is now:
HTML Code:
http://maps.google.com/maps/api/js?v=3&sensor=false®ion=au&language=en&key=xxxxxxxxxxxxxxxxxx
Success: Most importantly the "Google Maps JavaScript API" Usage page is NOW showing activity, hence the KEY is been received by Google.
But still in "Firefox Firebug Console" I am getting the error:
HTML Code:
Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
After reading up on Google Maps API, the "sensor=false" and the "v=3" values provided in the URL are not required anymore.
I removed these from "vantage\includes\geo\map-providers\google-maps.php" code:
From:
PHP Code:
$params = array(
'v' => 3,
'sensor' => 'false',
'region' => $options['geo_region'],
'language' => $options['geo_language'],
)
To:
PHP Code:
$params = array(
'region' => $options['geo_region'],
'language' => $options['geo_language'],
);
After this change, the Maps are working in Vantage, "Google Maps JavaScript API" Usage page is receiving the key and no more map generated errors in Firefox Console.