我正在使用这个扩展Yii 框架:Jquery-gmap
我的应用程序我使用过$gmap->updateMarkerAddressFromModel
& $marker->capturePosition
。
但是使用$gmap->updateMarkerAddressFromModel
时不工作$marker->capturePosition
,否则$gmap->updateMarkerAddressFromModel
单独使用时工作正常。
我的代码
<?php
Yii::import('ext.jquery-gmap.*');
$gmap = new EGmap3Widget();
$gmap->setSize(400, 234);
// base options
$options = array(
'scaleControl' => true,
'zoom' => 15,
'center' => array(0, 0),
'mapTypeId' => EGmap3MapTypeId::ROADMAP,
'mapTypeControlOptions' => array(
'style' => EGmap3MapTypeControlStyle::DROPDOWN_MENU,
'position' => EGmap3ControlPosition::TOP_CENTER,
),
);
$gmap->setOptions($options);
// marker with custom icon
$marker = new EGmap3Marker(array(
'draggable' => true,
));
$marker->address = 'London';
$marker->capturePosition(
// the model object
$businessModel,
// model's latitude property name
'lat',
// model's longitude property name
'longi',
array('drag')
);
// tell the gmap to update the marker from the model fields.
$gmap->updateMarkerAddressFromModel(
// the model object
$businessModel,
array('street','town','country'),
array('zoom'=>16)
);
$marker->centerOnMap();
$gmap->add($marker);
$gmap->renderMap();
?>