jquery-gmap with CJuiAutoComplete

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

hi rahul,

I am looking the same thing. Did you finally made it?

After some testing, I find out that the problem is at the marker. A variable is undefined, I will check it out later.

no i am still not able to do it. please tell me(with example code) if you found the correct way of doing it.

this is the code with autocomplete only

pastebin.com/0dBbB14P I cannot enter a link yet, I am not allowed by the forum. You can add http

I haven’ t finished with adress

Still it is not working for me. Can you post your full code with map so that i can get more idea.

http://pastebin.com/2nnvnSR1

Hi giannis,

It working cool now :). Now I am able to fetch the address and save it. Thanks for your help.

Previously I was not setting the gmap->id property… silly mistake. You solved my problem. Thanks again

You can check it on www.ixpense.net

Nice, I am glad to help you. Nice work too

Giannis, i ´m having an arror when try to enter this code, like if the id is missing…

Can you copy all the code, gmap and autocomplete, please?

Regards.