Yii Framework Forum

Egmap NoApiKeys problem

(massimop1973) #1

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:

$gMap = new EGMap();
$gMap->zoom = 10;
$mapTypeControlOptions = array(
  'position'=> EGMapControlPosition::LEFT_BOTTOM,
$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?

// 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));


<style type="text/css">

where I wrong? Thank you