I’m using this extension http://www.yiiframework.com/extension/jquery-gmap/
Im my application I’ve used “$gmap->updateMarkerAddressFromModel” & “$marker->capturePosition”. But $gmap->updateMarkerAddressFromModel is not working when $marker->capturePosition is used, otherwise $gmap->updateMarkerAddressFromModel is working fine when used alone. Plz help
my code:
<?php
Yii::import('ext.jquery-gmap.*');
$gmap = new EGmap3Widget();
$gmap->setSize(400, 234);
// base options
$options = array(
'scaleControl' => true,
//'streetViewControl' => false,
'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->latLng = array(0, 0);
$marker->address = 'London';
$marker->capturePosition(
// the model object
$businessModel,
// model's latitude property name
'lat',
// model's longitude property name
'longi',
// Options set :
// show the fields, defaults to hidden fields
// update the fields during the marker drag event
array('drag')
);
// tell the gmap to update the marker from the model fields.
$gmap->updateMarkerAddressFromModel(
// the model object
$businessModel,
// the model attributes to capture, these MUST be present in the form
// constructed above. Attributes must also be given in the correct
// order for assembling the address string.
array('street','town','country'),
// you may pass these options :
// 'first' - set to first marker added to map, default is last
// 'nopan' - do not pan the map on marker update.
array('zoom'=>16)
);
$marker->centerOnMap();
$gmap->add($marker);
$gmap->renderMap();
?>