Yii Framework Forum: Dynamically Update Google Map Based On User Query - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Dynamically Update Google Map Based On User Query How to pass text values into google map?

#1 User is offline   Selvakumar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 135
  • Joined: 14-August 13
  • Location:Bangalore, India

Posted 08 January 2014 - 05:15 AM

Hi, I am using this extension to display the google map in my page. And i have a text field that have been adding dynamically. I want to display the text field values in the google map. How to pass the text field values into the google map functionality.
view.php
<div id="map_section">
	<div class="country_travell" style="background-color: #F8F8F8">
    <?php
	foreach($countriesTravelled as $i => $countryTravelled) {
		$isCloseRequired = ($i==0) ? false : true;
		$this->renderPartial('_country_travelled', array('countryTravelled'=> $countryTravelled,
			'i' => $i, // Row or iterator
                        'form'=>$form,
            		'isCloseRequired'=>$isCloseRequired));
	}
    ?>
</div>
	</div>
	<div id="gmap">
		<?php $this->renderPartial('gmap',array('flagMap1'=>$flagMap)); ?>
	</div>

_country_travelled.php
        <div class="floatLeft txt-input" rel="col1" style="width:150px;">
	<?php
	    echo $form->textField($countryTravelled, "[$i]place", array('onchange'=>'getPlaceName(this.value);', 'style' => 'width: 150px;'));
	?>
	</div>

script.js
function getPlaceName(vl) {
    	alert(vl);

	$.ajax({
		type: 'POST',
		url: '<?php echo Yii::app()->createUrl("site/showGmap"); ?>',
		data:'place='+vl,
			success:function(data) {
				// alert(data);
				// if success
			$("#gmap").append(data);
			jQuery("#gmap").load("<?php echo Yii::app()->createUrl('site/showGmap'); ?>");
		},
			error: function(data) { // if error occured
			alert("Error occured...! Please try again");
		},
		 dataType:'html'
	});

		// $("#gmap").load("gmap.php");
    }

Controller.php
public function actionShowGmap() {
	$place=$_POST["place"];
	// echo $place; exit;
	[b]$this->render('gmap', array('place'=>$place));[/b]
 }

In the controller i'm getting the value of place. and i want to pass the same place value in to the gmap.
Please anyone help me :(
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users