You are here

function template_preprocess_getlocations_fields_view_streetview in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/views/getlocations_fields.views.inc \template_preprocess_getlocations_fields_view_streetview()

Preprocess function for getlocations_fields_view_streetview.tpl. getlocations_fields module only

File

modules/getlocations_fields/views/getlocations_fields.views.inc, line 737
getlocations_fields.views.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function template_preprocess_getlocations_fields_view_streetview(&$variables) {
  global $language;

  // just in case
  if (!getlocations_fields_streetview_settings_allow()) {
    $variables['mapid'] = FALSE;
    return;
  }
  $locations = $variables['view']->style_plugin->rendered_fields;
  $options = $variables['view']->style_plugin->options;
  $latlons = array();
  if (count($locations) == 1) {
    $location = $locations[0];
    $lid = 0;
    if (isset($location['glid']) && $location['glid'] > 0 && isset($location['latitude']) && isset($location['longitude'])) {
      $lid = $location['glid'];
    }
    if ($lid > 0) {

      // dump bummers with no lat/lon
      if ($latlon = getlocations_latlon_check($location['latitude'] . ',' . $location['longitude'])) {
        $ll = explode(',', $latlon);
        $location['latitude'] = $ll[0];
        $location['longitude'] = $ll[1];

        // get defaults
        $dvals = getlocations_fields_data_keys('d');
        $options['sv_heading'] = isset($location['data']) && is_numeric($location['data']) ? $location['data'] : $dvals['sv_heading'];
        $options['sv_zoom'] = isset($location['data_1']) && is_numeric($location['data_1']) ? $location['data_1'] : $dvals['sv_zoom'];
        $options['sv_pitch'] = isset($location['data_2']) && is_numeric($location['data_2']) ? $location['data_2'] : $dvals['sv_pitch'];
        $options['sv_enable'] = isset($location['data_3']) && is_numeric($location['data_3']) ? $location['data_3'] : $dvals['sv_enable'];
        $getlocations_defaults = getlocations_defaults();
        $newdefaults = getlocations_adjust_vars($getlocations_defaults, $options);
        $mapid = getlocations_setup_map($newdefaults, FALSE, TRUE);
        $options['latitude'] = $location['latitude'];
        $options['longitude'] = $location['longitude'];
        getlocations_fields_streetview_js_settings_do($options, $mapid);
        $variables['mapid'] = $mapid;
        $variables['width'] = $options['width'];
        $variables['height'] = $options['height'];
      }
    }
  }
}