Egmap NoApiKeys problem

Hi All,

Now for google geolocation access is required an api key, i have created one in the google maps site, all ok.
The problem start when i try to use it in my program, response is that the api key is not setted:

util.js:225 Google Maps JavaScript API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

a snipped of my program is:

<?php
Yii::import('ext.EGMap.*');
 
$gMap = new EGMap();
$gMap->zoom = 10;
$gMap->setWidth(235);
$gMap->setHeight(215);
$mapTypeControlOptions = array(
  'position'=> EGMapControlPosition::LEFT_BOTTOM,
  'style'=>EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU
);
 
$gMap->mapTypeControlOptions= $mapTypeControlOptions;
 
// the host is localhost, i am sure that the correct api key is take
if ((!is_null(ZSettings::getConf('settings_geotargeting_google_maps_api'))) &&
(ZSettings::getConf('settings_geotargeting_google_maps_api') != "")) {
if  (isset($_SERVER['SERVER_NAME'])) {
	$gMap->setAPIKey($_SERVER['SERVER_NAME'], ZSettings::getConf('settings_geotargeting_google_maps_api'));
} elseif (isset($_SERVER['HTTP_HOST'])) {
	$gMap->setAPIKey($_SERVER['HTTP_HOST'], ZSettings::getConf('settings_geotargeting_google_maps_api'));
}

}

// Test, the response is: null
// the apiKey is not setted!!!!!!! why?
var_dump($gMap->getAPIKey());


// Create marker
if($model->coordinates && $model->coordinates != 'ERROR')
{
	$coords = explode(',',$model->coordinates);
	$gMap->setCenter($coords[0], $coords[1]);
	$marker = new EGMapMarker($coords[0], $coords[1], array('title' => $model->business_name));
	//$marker->addHtmlInfoWindow($info_window_a);
	$gMap->addMarker($marker);	
}

$gMap->renderMap();
?>

<style type="text/css">
	img{max-width:none}
</style>

where I wrong? Thank you

Hello i finded a solution

the problem is that the new google api policies requires the apikey at the end of the request

to do this i modified the extension like this:

in the file: EGMap.php

public function registerMapScript($afterInit=array(), $language = null, $region = null, $position = CClientScript::POS_LOAD)
	{
		// TODO: include support in the future
		//$params = 'sensor=false';
		$params = '';

		if ($language !== null)
			$params .= '&language=' . $language;
		if ($region !== null)
			$params .= '&region=' . $region;

		// ********* start of hack!!
		// get the api key from setting
		$key = ZSettings::getConf('settings_geotargeting_google_maps_api');

		if ($key !== null)
			$params .= '&key='. $key;
		// ********* end of hack

		CGoogleApi::init();
		CGoogleApi::register('maps', '3', array('other_params' => $params));

in the file: EGMapClient.php

class EGMapClient
{
	/**
	 * The URL for the RESTful geocode API.
	 * @since 2011-03-23 Matt Cheale Updated URL from v2 to v3 of the API.
	 * @since 2011-04-21 Matt Cheale Removed the format option so it can be customised in the geocoding methods.
	 * @since 2011-12-19 Antonio Ramirez renamed to make use of more APIs
	*/
        // ****************** added 's' in http 
	const API_GEOCODE_URL = 'https://maps.googleapis.com/maps/api/geocode/';
	/**
	 * The URL for the RESTful elevation API
	 */
	const API_ELEVATION_URL = 'https://maps.googleapis.com/maps/api/elevation/';