Hi Yii developers
I am trying to do GOOGLE MAPS ADDRESS LOOKUP WITH AUTO COMPLETION
but I am not able to follow the yii method.
here is my code for CJuiAutoComplete
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'model'=>$model,
'attribute'=>'place',
'id'=>'place',
'name'=>'place',
'source'=>'js:function(request, response) {
$("#gmap").gmap3({
action:"getAddress",
place: request.term,
callback:function(results){
if (!results) return;
response($.map(results, function(item) {
return {
label: item.formatted_address,
value: item.formatted_address,
latLng: item.geometry.location
}
}));
}
});,
'htmlOptions'=>array(
'size'=>'40'
),
));
and for jquery-gmap
<?php
Yii::import('ext.jquery-gmap.*');
// create a map centered in the middle of the world ...
$gmap = new EGmap3Widget();
$gmap->setSize(500, 180);
$gmap->setOptions(array(
'zoom' => 2,
'center' => array(10,10),
));
// add a marker
$marker = new EGmap3Marker(array(
'title' => 'My place of expense',
'draggable'=>false,
));
$marker->latLng = array(0,0);
$marker->address = $model->place;
$gmap->add($marker);
// tell the gmap to update the marker from the Address model fields.
$gmap->updateMarkerAddressFromModel(
// the model object
$model,
array('place'),
array()
);
$gmap->renderMap();
?>
This code is not at all working niether i am getting anything in autocomplete nor the jquery-gmap marker get updated after entering address into textbox. Without CJuiAutoComplete textbox map is getting updated. Please help me to solve this pblm.
thank you