我正在试图在局部视图上加载EGMap。这是我的代码:
这是调用动作loadmap的ajax按钮:
echo CHtml::ajaxsubmitButton ("Press for geolocation",
CController::createUrl('organization/loadmap'),
array('update' => '#formMap'));
动作加载图:
$this->renderPartial('_loadMap',array('model'=>$model),false,true);
最后是局部视图:
$address = $model->address . ", " . City::model()->giveLocation($model->cityID);
echo $address;
Yii::import('ext.EGMap.*');
$gMap = new EGMap();
$gMap->zoom = 5;
$gMap->width = '100%';
$gMap->height = 200;
$mapTypeControlOptions = array(
'position'=> EGMapControlPosition::RIGHT_TOP,
'style'=>EGMap::MAPTYPECONTROL_STYLE_DEFAULT,
);
$gMap->mapTypeId = EGMap::TYPE_HYBRID;
$gMap->mapTypeControlOptions= $mapTypeControlOptions;
// Create geocoded address
$geocoded_address = new EGMapGeocodedAddress($address);
$geocoded_address->geocode($gMap->getGMapClient());
// Center the map on geocoded address
$gMap->setCenter($geocoded_address->getLat(), $geocoded_address->getLng());
// Add marker on geocoded address
$gMap->addMarker(
new EGMapMarker($geocoded_address->getLat(), $geocoded_address->getLng())
);
$gMap->renderMap();
网站加载div但不加载地图。任何建议???
萤火虫说:谷歌没有定义
非常感谢!!!
答案 0 :(得分:1)
我发现它在renderPartial
中无法使用Iframe
并且您可以更新其src
事件。这对我有用了