How to alter the search api views exposed form field value? I have a search api view. Which has an exposed some exposed filters.

The exposed filters contains postal code, city and latlong field.

The user will enter the city and postal code and then in the code I will get a latlong from that address and will assign to the latlong field.

I have tried the following code but it is not working.

function mymodule_form_views_exposed_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form['#id'] == 'views-exposed-form-id') {
    array_unshift($form['#submit'], 'mymodule_maps_exposed_form_submit');
  }
}

function mymodule_maps_exposed_form_submit(&amp;$form, &amp;$form_state) {
  $address = $form_state['values']['zipcode'] . ' ' . $form_state['values']['city'];
  $latlong = somefunction($address);
  // Tried all of these options but nothing is working.
  $form_state['values']['latlong'] = $latlong;
  $form_state['input']['latlong'] = $latlong;
  $form_state['view']-&gt;exposed_input['latlong'] = $latlong;
  $form_state['view']-&gt;display_handler-&gt;handlers['filter']['latlong']-&gt;validated_exposed_input = $latlong;
  $form_state['view']-&gt;display_handler-&gt;handlers['filter']['latlong']-&gt;value = $latlong;
  // This line adds the value to the form field but the filter doesn't apply.
  $form_state['complete form']['latlong']['#value'] = $latlong;
  $form_state['complete form']['latlong']['#default_value'] = $latlong;
}


Is there any trick I am missing? Can someone guide me? Anyone who can give  a hint?
I have found an answer. I am sharing it here so that it can help someone.

Instead of form_alter hook, we can use hook_views_pre_view.

Here is the code

/**
 * Implements hook_views_pre_view().
 */
function mymodule_views_pre_view(&amp;$view, &amp;$display_id, &amp;$args) {
  if ($view-&gt;name == 'my_view_name') {
    $address = 'some address';
    $latlong = somefunction($address);
    $view-&gt;get_exposed_input();
    $view-&gt;exposed_input['latlon'] = $latlon;
    $view-&gt;execute().
  }
}