You are here

function theme_getlocations_leaflet_map in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_leaflet/getlocations_leaflet.module \theme_getlocations_leaflet_map()

Function

Return value

Returns

4 theme calls to theme_getlocations_leaflet_map()
getlocations_leaflet_entity_type_map in modules/getlocations_leaflet/getlocations_leaflet.module
Function
getlocations_leaflet_field_formatter_view in modules/getlocations_leaflet/getlocations_leaflet.module
Implements hook_field_formatter_view(). Build a renderable array for a field value.
template_preprocess_getlocations_leaflet_view_map in modules/getlocations_leaflet/views/getlocations_leaflet.views.inc
Preprocess function for getlocations_leaflet_view_map.tpl
theme_getlocations_leaflet_settings_form in modules/getlocations_leaflet/getlocations_leaflet.module
Function

File

modules/getlocations_leaflet/getlocations_leaflet.module, line 5303
getlocations_leaflet.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function theme_getlocations_leaflet_map($variables) {
  drupal_add_library('getlocations_leaflet', 'getlocations-leaflet');
  drupal_add_css(GETLOCATIONS_LEAFLET_PATH . '/getlocations_leaflet.css');
  $width = $variables['width'];
  $height = $variables['height'];
  $map_settings = $variables['map_settings'];
  $mapid = $variables['mapid'];
  $links = $variables['links'];
  $datanum = $map_settings['datanum'];
  $latlons = $map_settings['latlons'];
  $icons = $map_settings['icons'];
  $minmaxes = $map_settings['map_settings']['minmaxes'];
  $show_maplinks = $map_settings['map_settings']['show_maplinks'];
  unset($map_settings['datanum']);
  unset($map_settings['latlons']);
  unset($map_settings['icons']);
  unset($map_settings['map_settings']['minmaxes']);
  getlocations_leaflet_js_settings_do($map_settings, $mapid);
  $output = '';

  // links
  if (isset($links['returnlink'])) {
    $output .= '<div class="getlocations_returnlink">' . $links['returnlink'] . '</div>';
  }

  // wrap the map
  $output .= '<div class="getlocations_leaflet_map_wrapper_inner">';
  $output .= '<div id="getlocations_leaflet_wrapper_' . $mapid . '"  style="width: ' . $width . '; height: ' . $height . '" >';
  $output .= '<div class="getlocations_leaflet_canvas" id="getlocations_leaflet_canvas_' . $mapid . '" style="width: 100%; height: 100%" ></div>';
  $output .= '</div>';
  $output .= '</div>';

  // give each map its own data
  $localdata = json_encode(array(
    'datanum' => $datanum,
    'latlons' => $latlons,
    'icons' => $icons,
    'minmaxes' => $minmaxes,
  ));
  $output .= "\n" . '<script type="text/javascript">' . "\n" . '<!--//--><![CDATA[//><!--' . "\n";
  $output .= 'Drupal.getlocations_leaflet_data["' . $mapid . '"] = ' . $localdata . ';' . "\n";
  $output .= '//--><!]]>' . "\n" . '</script>' . "\n";

  // show_search_distance etc
  if (module_exists('getlocations_fields') && isset($map_settings['search_dist_info'])) {
    $output .= '<div id="getlocations_fields_search_views_search_wrapper_' . $mapid . '" class="js-hide">';
    $output .= '<div id="getlocations_fields_search_views_search_units_' . $mapid . '">' . $map_settings['search_dist_info']['search_units'] . '</div>';
    $output .= '<div id="getlocations_fields_search_views_search_latitude_' . $mapid . '">' . $map_settings['search_dist_info']['latitude'] . '</div>';
    $output .= '<div id="getlocations_fields_search_views_search_longitude_' . $mapid . '">' . $map_settings['search_dist_info']['longitude'] . '</div>';
    $output .= '<div id="getlocations_fields_search_views_search_distance_meters_' . $mapid . '">' . getlocations_convert_distance_to_meters($map_settings['search_dist_info']['search_distance'], $map_settings['search_dist_info']['search_units']) . '</div>';
    $output .= '</div>';
  }

  // show maplinks if enabled
  if ($show_maplinks) {
    $output .= '<div class="getlocations_leaflet_map_links" id="getlocations_leaflet_map_links_' . $mapid . '" ><ul></ul></div>';
  }

  // buttons
  $buttons = array();

  // usermarker
  $geolocation_mobile_check = $map_settings['map_settings']['geolocation_mobile_check'] ? FALSE : TRUE;
  if (getlocations_is_mobile($geolocation_mobile_check) && $map_settings['map_settings']['usermarker']) {
    $buttons[] = '<input type="button" value="' . $map_settings['map_settings']['usermarker_button_label'] . '" id="getlocations_leaflet_gps_show_' . $mapid . '" class="form-submit"  /><div class="getlocations_leaflet_gps_throbber getlocations_leaflet_gps_throbber_inactive" id="getlocations_leaflet_gps_throbber_' . $mapid . '">&nbsp;&nbsp;&nbsp;&nbsp;</div>';
  }

  // views_search_marker
  if (module_exists('getlocations_fields') && isset($map_settings['search_dist_info'])) {
    if ($map_settings['map_settings']['views_search_marker_enable'] && $map_settings['map_settings']['views_search_marker_toggle']) {
      $buttons[] = '<input type="button" value="' . t('Search marker !t', array(
        '!t' => $map_settings['map_settings']['views_search_marker_toggle_active'] ? t('Off') : t('On'),
      )) . '" id="getlocations_leaflet_toggleSearchMarker_' . $mapid . '" class="form-submit" />';
    }
    if ($map_settings['map_settings']['views_search_radshape_enable'] && $map_settings['map_settings']['views_search_radshape_toggle']) {
      $buttons[] = '<input type="button" value="' . t('Search area !t', array(
        '!t' => $map_settings['map_settings']['views_search_radshape_toggle_active'] ? t('Off') : t('On'),
      )) . '" id="getlocations_leaflet_toggleSearchArea_' . $mapid . '" class="form-submit" />';
    }
  }
  if (count($buttons)) {
    $output .= '<div class="getlocations_leaflet_map_buttons container-inline">';
    $output .= implode('&nbsp;', $buttons);
    $output .= '</div>';
  }

  // What3Words
  $what3words_lic = variable_get('getlocations_what3words_lic', array(
    'key' => '',
    'url' => 'http://api.what3words.com',
  ));
  if ($what3words_lic['key'] && $map_settings['map_settings']['what3words_enable']) {
    $output .= '<div class="getlocations_leaflet_what3words container-inline">';
    if ($map_settings['map_settings']['what3words_search']) {

      // textbox
      $output .= t('What3Words') . '&nbsp;&nbsp;<input type="text" id="edit-getlocations-leaflet-what3words-search" name="edit-getlocations-leaflet-what3words-search" value="" size="' . $map_settings['map_settings']['what3words_size'] . '" class="form-text" />';
      $output .= '&nbsp;&nbsp;<input type="button" value="' . t('Search') . '" id="edit-getlocations-leaflet-what3words-search-submit" class="form-submit" />';
      $output .= '<div class="getlocations_w3w_throbber getlocations_w3w_throbber_inactive" id="getlocations_w3w_throbber_' . $mapid . '">&nbsp;&nbsp;&nbsp;&nbsp;</div>';
      $output .= '<br />';
    }
    if ($map_settings['map_settings']['what3words_show']) {
      $output .= '<div id="edit-getlocations-leaflet-what3words-show"></div>';
    }
    $output .= '</div>';
  }
  return $output;
}