Drupal7:在 select 的 3 个州、城市和分支下拉列表中,它应该显示带有 Google 地图的地址吗?我应该怎么做给我建议?

Drupal7: On select of 3 dropdown list of state, city and branch it should display the address with Google map? How should i do it give me suggestions?

  1. 创建表单并将值存储在数据库中
  2. $form["contact_options"]["state_select"] = 数组( "#type" => "select", "#title" => t("Select your state"), "#options" => $states_types, "#description" => t("Select state."), '#attributes' => array('id' => array('SelectType'), 'onchange' => 'getState(this.value)'), );

  3. 从数据库中获取值。

  4. 关于使用变化值。如果我 select 州的价值,我如何根据我从数据库中选择的州分配给另一种形式并获得城市的结果。
  $form['ver_ajax_dropdown']['state'] = array(
   '#title' => t('State'),
   '#type' => 'select',
   '#options' => _load_state(),
   '#ajax' => array(
   'event'=>'change',
   'callback' =>'ver_ajax_dropdown_city',
   'wrapper' => 'city-wrapper',
   ),
 );

  $options = array('- Select City -');
 if (isset($form_state['values']['state'])) {
 $options = _load_city($form_state['values']['state']);
}

$form['ver_ajax_dropdown']['city'] = array(
'#title' => t('City'),
'#type' => 'select',
'#prefix' => '<div id="city-wrapper">',
'#suffix' => '</div>',
 '#options' => $options,
'#ajax' => array(
  'event'=>'change',
  'callback' =>'ver_ajax_dropdown_branch',
  'wrapper' => 'branch-wrapper',
),
);

 $branch_options = array('- Select Branch -');
  if (isset($form_state['values']['city'])) {
   $branch_options = _load_branch($form_state['values']['city']);
 }

 $form['ver_ajax_dropdown']['branch'] = array(
  '#title' => t('Branch'),
  '#type' => 'select',
  '#prefix' => '<div id="branch-wrapper">',
  '#suffix' => '</div>',
  '#options' => $branch_options,
  '#ajax' => array(
  'wrapper' => 'contact_ajax_wrapper',
  'callback' => 'contact_form_ajax',
  ), 
 );

 function ver_ajax_dropdown_city($form, $form_state) {
  return $form['ver_ajax_dropdown']['city'];
 }
 function ver_ajax_dropdown_branch($form, $form_state) {
  return $form['ver_ajax_dropdown']['branch'];
 }
 function contact_form_ajax($form, $form_state) {
  return $form['results'];
  }


 function _load_state() {

  $state = array('- Select State -');
  $query = db_select("vercontact_mapping", "a");
  $query->distinct();
  $query->fields("a", array('state'));
  $query->orderBy("a.state");
  $result = $query->execute();

  while($row = $result->fetchObject()){
  $state[$row->state] = $row->state;
  }
  //print_r($province);
  return $state;
 }

 function _load_city($state) {
  $city = array('- Select City -');
  $query = db_select("vercontact_mapping", "a");
  $query->distinct();
  $query->fields("a", array('state','city'));
  $query->condition("a.state", $state);
  $query->orderBy("a.city");
  $query->groupBy("a.city");  
  $result = $query->execute();

 while($row = $result->fetchObject()){
  $city[$row->city] = $row->city;
 }
 //print_r($city);
  return $city;
 }
 function _load_branch($city) {
  $branch = array('- Select Branch -');
  $query = db_select("vercontact_mapping", "a");
  $query->distinct();
  $query->fields("a", array('city','branch'));
  $query->condition("a.city", $city);
  $query->orderBy("a.branch");
  $query->groupBy("a.branch");  
  $result = $query->execute();

  while($row = $result->fetchObject()){
   $branch[$row->branch] = $row->branch;
  }


 return $branch;
}