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