Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6990963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:25:41+00:00 2026-05-27T19:25:41+00:00

I am using egmaps extensions with Yii application it is a very brilliant application.

  • 0

I am using egmaps extensions with Yii application it is a very brilliant application. how ever I am having trouble populating database. my database table hotel has two attributes for long and lat. I am not expert in AJAX but i think that ajax is calling controler method. At present I donot have anything in controler method because I donot know what data will come and how?

my code so far is BUT I THINK THIS AJAX IS NOT CALLING THE CONTROLLER SaveCoordinates action

 $gMap->zoom = 6;
            $mapTypeControlOptions = array(
              'position' => EGMapControlPosition::RIGHT_TOP,
              'style' => EGMap::MAPTYPECONTROL_STYLE_HORIZONTAL_BAR
            );

            $gMap->mapTypeId = EGMap::TYPE_ROADMAP;
            $gMap->mapTypeControlOptions = $mapTypeControlOptions;

            // Preparing InfoWindow with information about our marker.
            $info_window_a = new EGMapInfoWindow("<div class='gmaps-label' style='color: #000;'>Hi! I'm your marker!</div>");

            // Setting up an icon for marker.
            $icon = new EGMapMarkerImage("http://google-maps-icons.googlecode.com/files/car.png");

            $icon->setSize(32, 37);
            $icon->setAnchor(16, 16.5);
            $icon->setOrigin(0, 0);

            // Saving coordinates after user dragged our marker.
            $dragevent = new EGMapEvent('dragend', 'function (event) { $.ajax({
                                                        type:"POST",
                                                        url:"'.$this->createUrl('hotel/savecoords').'/'.$model->id.'",
                                                        data:({lat: event.latLng.lat(), lng: event.latLng.lng()}),

                                                        cache:false,
                                                    });}', false, EGMapEvent::TYPE_EVENT_DEFAULT);
if($model->long)
{
            // If we have already created marker - show it
                $marker = new EGMapMarker($model->lat, $model->long, array('title' => Yii::t('catalog', $model->name),
                        'icon'=>$icon, 'draggable'=>true), 'marker', array('dragevent'=>$dragevent));
                $marker->addHtmlInfoWindow($info_window_a);
                $gMap->addMarker($marker);
                $gMap->setCenter($model->lat, $model->long);
                $gMap->zoom = 16;
}
else
{
                // Setting up new event for user click on map, so marker will be created on place and respectful event added.
                $gMap->addEvent(new EGMapEvent('click',
                        'function (event) {var marker = new google.maps.Marker({position: event.latLng, map: '.$gMap->getJsName().
                        ', draggable: true, icon: '.$icon->toJs().'}); '.$gMap->getJsName().
                        '.setCenter(event.latLng); var dragevent = '.$dragevent->toJs('marker').
                        '; $.ajax({'.
                          '"type":"POST",'.
                          '"url":"'.$this->createUrl('hotel/savecoords')."/".$model->id.'",'.
                          '"data":({"lat": event.latLng.lat(), "lng": event.latLng.lng()}),'.
                          '"cache":false,'.
                        '}); }', false, EGMapEvent::TYPE_EVENT_DEFAULT_ONCE));
}
            $gMap->renderMap(array(), Yii::app()->language);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:25:42+00:00Added an answer on May 27, 2026 at 7:25 pm

    Solved in case other may get stuck I solved it by changing POST to GET and URL Line

    url:"'.$this->createUrl('hotel/savecoords').'/'.$model->id.'", '
    

    to

    url':'".$this->createUrl('hotel/savecoords', array('id'=>$model->id))."',`
    

    and controller code is

     public function actionSaveCoords($id)
            {
                $model=$this->loadModel($id);
    
            // Uncomment the following line if AJAX validation is needed
                    // 
            // $this->performAjaxValidation($model);
                if(isset ($_GET['lat']))
                    $model->lat = $_GET['lat'];
                if(isset ($_GET['lat']))
                    $model->long = $_GET['lng'];
                if($model->save())
                    {
                        echo 'Thank you for registring your place with '.Yii::app()->name;  
                    }
                    $this->render('view',array(
                'model'=>$model,
            ));
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using C#, I need a class called User that has a username, password, active
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using Android TelephonyManager an application can obtain the state of data activity over the
Using emacs on Ubuntu 11.10. I want to connect to a SQL Server database
Using SQL Server 2005 Leave Table ID StartDate EndDate 001 02/03/2010 02/03/2010 002 02/03/2010
Using PHP and MySQL, I want to query a table of postings my users
using SQL Server 2005 standard edition with SP2 I need to design a table
Using mysql, c#.net, Java Script I have the web application, i want to create
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.