title: Yii and EGMap extension (Google Map) refresh map on checkbox changes
body: <p>I'm developing an interactive map using <a href="http://www.yiiframework.com/" rel="nofollow noreferrer">Yii framework</a> and Yii <a href="http://www.yiiframework.com/extension/egmap" rel="nofollow noreferrer">egmap extension</a>.
  I would like to refresh the map (ajax) when user click on checkboxes as shown in the picture:
  <img src="https://i.stack.imgur.com/S8xX2.png" alt="yii-egmap-screenshot">
  I'm only able to do it server-side (refresh the whole page) with the following code:</p>
  
  <pre><code>&lt;?php
      Yii::app()-&gt;clientScript-&gt;registerScript('filterscript',"
          $('#filter_all').click(function() {
              $(\"input[name='filter\[\]']\").prop('checked', this.checked);
              window.location.href = 'http://' + window.location.host + window.location.pathname + '?tags=sale,rent,residential,commercial,agricultural';
          });
          $(\"input[name='filter\[\]']\").click(function() {
              var tags = '?tags=';
              var tmp=new Array();
              $('#filter_all').prop('checked', !$(\"input[name='filter\[\]']:not(:checked)\").length);
              $('input[type=checkbox]').each(function () {
                  if (this.checked) 
                      tmp.push($(this).val());
  
              });
              tags += tmp.join(',');
              window.location.href = 'http://' + window.location.host + window.location.pathname + tags;
          });
          $('#filter_all').prop('checked', !$(\"input[name='filter\[\]']:not(:checked)\").length);
      ",CClientScript::POS_READY);
  ?&gt;
  </code></pre>
  
  <p>And the map is generated using the EGMap extension with this code:</p>
  
  <pre><code>&lt;?php
  
  // Get latlong from location-aware web browser saved in cookie
  if (isset($_COOKIE['latlng'])){
      list($lat,$long) = explode(',',htmlentities(htmlspecialchars(strip_tags($_COOKIE['latlng']))));
  }else{
      $lat = 3.159553312559541;
      $long = 101.71481802016604;
  }
  Yii::import('ext.gmap.*');
  
  $gMap = new EGMap();
  $gMap-&gt;setJsName('map');
  $gMap-&gt;zoom = 10;
  $mapTypeControlOptions = array(
      'sensor'=&gt;true,
      'position'=&gt; EGMapControlPosition::LEFT_BOTTOM,
      'style'=&gt;EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU
  );
  
  $gMap-&gt;mapTypeControlOptions= $mapTypeControlOptions;
  $gMap-&gt;setWidth('100%');
  $gMap-&gt;setHeight(500);
  $gMap-&gt;setCenter($lat, $long);
  
  $icon = new EGMapMarkerImage("http://".$_SERVER['HTTP_HOST'].Yii::app()-&gt;baseUrl."/images/bighouse.png");
  
  $icon-&gt;setSize(32, 37);
  $icon-&gt;setAnchor(16, 16.5);
  $icon-&gt;setOrigin(0, 0);
  
  // Status label
  $status_type = array(
      0=&gt;'success',
      1=&gt;'warning',
      2=&gt;'important',
      3=&gt;'important',
  );
  
  $condition = '';
  $sale_cond = '';
  $rent_cond = '';
  
  if ($match['sale']==='' &amp;&amp; $match['rent']==='' &amp;&amp; $match['residential']==='' &amp;&amp; $match['commercial']==='' &amp;&amp; $match['agricultural']===''){
      $condition = "AND (
          (MATCH (tags) AGAINST ('sale') 
          AND MATCH (tags) AGAINST ('residential'))
          OR
          (MATCH (tags) AGAINST ('rent') 
          AND MATCH (tags) AGAINST ('residential') )
          OR
          (MATCH (tags) AGAINST ('sale') 
          AND MATCH (tags) AGAINST ('commercial'))
          OR
          (MATCH (tags) AGAINST ('rent') 
          AND MATCH (tags) AGAINST ('commercial') )
          OR
          (MATCH (tags) AGAINST ('sale') 
          AND MATCH (tags) AGAINST ('agricultural'))
          OR
          (MATCH (tags) AGAINST ('rent') 
          AND MATCH (tags) AGAINST ('agricultural') )
      )";
  }else{
      if ($match['sale']!=''){
          $sale_cond = "MATCH (tags) AGAINST ('sale')";
          if ($match['residential']!=''){
              $cond[1] = "(".$sale_cond." AND MATCH (tags) AGAINST ('residential'))";
          }
          if ($match['commercial']!=''){
              $cond[2] = "(".$sale_cond." AND MATCH (tags) AGAINST ('commercial'))";
          }
          if ($match['agricultural']!=''){
              $cond[3] = "(".$sale_cond." AND MATCH (tags) AGAINST ('agricultural'))";
          }
          if ($match['residential']!='' || $match['commercial']!='' || $match['agricultural']!=''){
              $sale_cond = implode(' OR ', $cond);
          }
      }
      if ($match['rent']!=''){
          $rent_cond = "MATCH (tags) AGAINST ('rent')";
          if ($match['residential']!=''){
              $cond[1] = "(".$rent_cond." AND MATCH (tags) AGAINST ('residential'))";
          }
          if ($match['commercial']!=''){
              $cond[2] = "(".$rent_cond." AND MATCH (tags) AGAINST ('commercial'))";
          }
          if ($match['agricultural']!=''){
              $cond[3] = "(".$rent_cond." AND MATCH (tags) AGAINST ('agricultural'))";
          }
          if ($match['residential']!='' || $match['commercial']!='' || $match['agricultural']!=''){
              $rent_cond = implode(' OR ', $cond);
          }
  
      }
      if ($sale_cond!=''){
          $condition = 'AND '.$sale_cond;
          if ($rent_cond!=''){
              $condition .= ' OR '.$rent_cond;
          }
      }elseif ($rent_cond!=''){
          $condition = 'AND '.$rent_cond;
      }
  }
  
  $props = Property::model()-&gt;findAll('active=1 '.$condition);
  if ($props!==null){
      foreach ($props as $prop){
          // Prepare status label for info box
          $status_label='&lt;span class="label label-'.$status_type[(int)$prop['status']].'"&gt;'.$list_status[(int)$prop['status']].'&lt;/span&gt;';
          $prop_photo = '';
          $win_height = '110px';
          // Check if photo exist
          if (is_file('images/property/'.$prop['photo'])){
              $prop_photo = '&lt;img src="http://'.$_SERVER['HTTP_HOST'].Yii::app()-&gt;baseUrl.'/images/property/'.$prop['photo'].'" /&gt;&lt;br /&gt;'; 
              $win_height = '310px';
          }
  
          $email_img = '&lt;img src="http://'.$_SERVER['HTTP_HOST'].Yii::app()-&gt;baseUrl.'/site/strtoimg?pid='.$prop['id'].'" /&gt;';
  
          $view_link = '&lt;div style="float:left"&gt;&lt;a href="'.Yii::app()-&gt;baseUrl.'/public/view/'.$prop['id'].'"&gt;View this property&lt;/a&gt;&lt;/div&gt;';
          $edit_link = '';
          if (!Yii::app()-&gt;user-&gt;isGuest &amp;&amp; (int)$prop['user_id']===(int)Yii::app()-&gt;user-&gt;id){
              $edit_link = '&lt;div style="float:right"&gt;&lt;a href="'.Yii::app()-&gt;baseUrl.'/prop/update/'.$prop['id'].'"&gt;Edit this property&lt;/a&gt;&lt;/div&gt;';
          }
          $links = '&lt;div&gt;'.$view_link.'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'.$edit_link.'&lt;/div&gt;';
  
          $info_window = new EGMapInfoWindow('&lt;div style="height:'.$win_height.'"&gt;'.
                  $prop_photo.
                  substr($prop['description'],0,40).'...'.'&lt;br /&gt;'.
                  'Price: '.$prop['price'].'&lt;br /&gt;'.
                  'Email: '.$email_img.'&lt;br /&gt;'.
                  'Tel: '.$prop['contact_phone'].'&lt;br /&gt;'.
                  $status_label.' Added: '.$prop['date_upload'].'&lt;br /&gt;'.
                  $links.
                  '&lt;/div&gt;');
          $marker = new EGMapMarker($prop['latitude'], $prop['longitude'], array('title' =&gt; $prop['title'],'icon'=&gt;$icon));
          $marker-&gt;addHtmlInfoWindow($info_window);
          $gMap-&gt;addMarker($marker);
      }
  }
  $gMap-&gt;renderMap();
  
  ?&gt;
  </code></pre>
  
  <p>All these codes are in the view file. The map is generated by the EGMap extension in the html element with id <code>EGMapContainer0</code>. Any idea how to achieve refreshing the map via ajax in the event of checkboxes clicks?</p>
  
  <p>Thanks.</p>