Jump to content
Larry Ullman's Book Forums
Selvakumar

Dynamically Update Google Map Based On User Query

Recommended Posts

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 :(

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...