Hello
I’m using the Yii egmap extension in order to generate maps of google maps. The problem is that when I generate them in a created tab with the CJuiTabs widget, the map doesn’t load and I get the following error:
ReferenceError: google is not defined
google.load("maps","3",{'other_params':'sensor=false'});
However, the map can be generated out of the tab. For example, if I open the browser and I load the URL: http://localhost/index.php?r=zonas/mapa&id=207 the map is generated.
Why does this problem happens? How can I solve it? Thank you.
Here I put the code.
CJuiTabs view:
?php
$this->widget('zii.widgets.jui.CJuiTabs',array(
'id'=>'zonas_tab',
'tabs'=>array(
Yii::t('default', 'Mapa')=>array('ajax'=>Yii::app()->createUrl('zonas/mapa', array('id'=>$model->id))),
Yii::t('default', 'Datos')=>array('ajax'=>Yii::app()->createUrl('zonas/datos', array('id'=>$model->id))),
Yii::t('default', 'Gráficas')=>array('ajax'=>Yii::app()->createUrl('zonas/grafica', array('id'=>$model->id))),
),
// additional javascript options for the tabs plugin
'options'=>array(
'collapsible'=>true,
),
));
?>
Controller action:
public function actionMapa($id)
{
$model = $this->loadModel($id);
$this->renderPartial('_viewMapa',array('model'=>$model),false,true);
}
Map view:
<?php
Yii::import('ext.gmap.*');
$gMap = new EGMap();
$gMap->setWidth('100%');
$gMap->setJsName('map');
$gMap->zoom = 10;
$mapTypeControlOptions = array(
'position'=> EGMapControlPosition::LEFT_BOTTOM,
'style'=>EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU
);
$gMap->mapTypeControlOptions= $mapTypeControlOptions;
$gMap->enableKMLService(Yii::app()->getBaseUrl(true).'/'.Yii::app()->params['dirMapas'].'microsectores.kml', true);
$gMap->renderMap();
?>