You are here

function getlocations_search_getmap in Get Locations 7.2

Same name and namespace in other branches
  1. 7 modules/getlocations_search/getlocations_search.module \getlocations_search_getmap()

Set up the map and use getlocations to spit it out

1 call to getlocations_search_getmap()
theme_getlocations_search in modules/getlocations_search/getlocations_search.module
Themes the search page.

File

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

Code

function getlocations_search_getmap($which = 'page') {
  $getlocations_defaults = getlocations_defaults();
  $getlocations_defaults['places'] = 1;
  $getlocations_defaults['preload_data'] = 0;
  $getlocations_search_defaults = getlocations_search_defaults();
  if ($which == 'block') {
    $getlocations_search_defaults = getlocations_search_block_get_var();
  }

  // we need a markermanager enabled
  if ($getlocations_defaults['markermanagertype'] < 1) {
    $getlocations_search_defaults['markermanagertype'] = 1;
  }
  $getlocations_search_defaults['pansetting'] = $getlocations_defaults['pansetting'];

  // we need to update $getlocations_defaults with data from $getlocations_search_defaults
  $keys = array(
    'width',
    'height',
    'styles',
    'latlong',
    'zoom',
    'minzoom_map',
    'maxzoom_map',
    'controltype',
    'pancontrol',
    'mtc',
    'maptype',
    'baselayers',
    'scale',
    'overview',
    'overview_opened',
    'scrollwheel',
    'draggable',
    'sv_show',
    'sv_showfirst',
    'sv_heading',
    'sv_zoom',
    'sv_pitch',
    'trafficinfo',
    'trafficinfo_state',
    'bicycleinfo',
    'bicycleinfo_state',
    'transitinfo',
    'transitinfo_state',
    'poi_show',
    'transit_show',
    'markeraction',
    'markeractiontype',
    'markeraction_click_zoom',
    'markeraction_click_center',
    'minzoom',
    'maxzoom',
    'nodezoom',
    'markermanagertype',
    'usemarkermanager',
    'useclustermanager',
    'markerclusterer_style',
    'markerclusterer_zoom',
    'markerclusterer_size',
    'markerclusterer_minsize',
    'markerclusterer_title',
    'markerclusterer_imgpath',
    'map_backgroundcolor',
    'show_maplinks',
    'show_maplinks_viewport',
    'fullscreen',
    'show_bubble_on_one_marker',
    'polygons_enable',
    'polygons_strokecolor',
    'polygons_strokeopacity',
    'polygons_strokeweight',
    'polygons_fillcolor',
    'polygons_fillopacity',
    'polygons_coords',
    'polygons_clickable',
    'polygons_message',
    'rectangles_enable',
    'rectangles_strokecolor',
    'rectangles_strokeopacity',
    'rectangles_strokeweight',
    'rectangles_fillcolor',
    'rectangles_fillopacity',
    'rectangles_coords',
    'rectangles_clickable',
    'rectangles_message',
    'circles_enable',
    'circles_strokecolor',
    'circles_strokeopacity',
    'circles_strokeweight',
    'circles_fillcolor',
    'circles_fillopacity',
    'circles_coords',
    'circles_radius',
    'circles_clickable',
    'circles_message',
    'polylines_enable',
    'polylines_strokecolor',
    'polylines_strokeopacity',
    'polylines_strokeweight',
    'polylines_coords',
    'polylines_clickable',
    'polylines_message',
    'kml_group',
    'map_resize',
    'region_bias',
    'fullscreen_disable',
    'fullscreen_controlposition',
    'search_places',
    'search_places_size',
    'search_places_position',
    'search_places_label',
    'search_places_placeholder',
    'search_places_dd',
    'search_places_list',
    'search_radshape_toggle',
    'search_radshape_toggle_active',
    'search_radshape_enable',
    'do_search_marker',
    'search_marker_toggle',
    'search_marker_toggle_active',
    'geo_enable',
    'geojson_enable',
    'geojson_data',
    'geojson_options',
    'nokeyboard',
    'nodoubleclickzoom',
    'zoomcontrolposition',
    'pancontrolposition',
    'mapcontrolposition',
    'scalecontrolposition',
    'svcontrolposition',
    'highlight_enable',
    'highlight_strokecolor',
    'highlight_strokeopacity',
    'highlight_strokeweight',
    'highlight_fillcolor',
    'highlight_fillopacity',
    'highlight_radius',
    'getdirections_link',
    'gps_button',
    'gps_button_label',
    'gps_marker',
    'gps_marker_title',
    'gps_bubble',
    'gps_geocode',
    'gps_center',
    'gps_type',
    'gps_zoom',
    'smartip_button',
    'smartip_button_label',
    'smartip_marker',
    'smartip_marker_title',
    'smartip_bubble',
    'smartip_center',
    'smartip_zoom',
    'smartip_callback',
    'geolocation_mobile_check',
    'geocoder_enable',
  );
  foreach ($keys as $key) {
    $getlocations_defaults[$key] = $getlocations_search_defaults[$key];
  }

  #if ($getlocations_search_defaults['use_geolocation_button']) {

  #  $getlocations_defaults['use_jsapi'] = 1;

  #}

  #$getlocations_defaults['extcontrol'] = 'getlocations_search';
  if (!$getlocations_search_defaults['showall']) {
    $getlocations_defaults['extcontrol'] = 'getlocations_search';
  }
  $mapid = getlocations_setup_map($getlocations_defaults);
  $aggr = getlocations_aggr_get() ? TRUE : FALSE;
  getlocations_search_js_settings_do($getlocations_search_defaults, $mapid);
  $getlocations_search_paths = getlocations_search_paths_get();
  $jsfile = $getlocations_search_paths['getlocations_search_path'];
  $js_opts = array();
  $js_opts['weight'] = $getlocations_defaults['getlocations_js_weight'] + 30;
  $js_opts['type'] = 'file';
  $js_opts['preprocess'] = $aggr;
  drupal_add_js($jsfile, $js_opts);
  $minmaxes = '';
  $latlons = array();

  ////////////////////////////////
  if ($getlocations_search_defaults['showall']) {
    $minmaxes = array(
      'minlat' => 0,
      'minlon' => 0,
      'maxlat' => 0,
      'maxlon' => 0,
    );
    $locations = getlocations_search_load_all_locations($getlocations_search_defaults['search_type']);
    $ct = 0;
    if (count($locations)) {

      // we should loop over them and dump bummers with no lat/lon
      foreach ($locations as $key => $location) {
        if ($latlon = getlocations_latlon_check($location['latitude'] . ',' . $location['longitude'])) {
          $ll = explode(',', $latlon);
          $location['latitude'] = $ll[0];
          $location['longitude'] = $ll[1];
          $minmaxes = getlocations_do_minmaxes($ct, $location, $minmaxes);
          if (!isset($location['key'])) {
            $location['key'] = '';
          }
          $id = 0;
          if (isset($location['lid']) && $location['lid']) {
            $id = $location['lid'];
          }
          elseif (isset($location['nid']) && $location['nid']) {
            $id = $location['nid'];
            $location['key'] = 'nid';
          }
          elseif (isset($location['uid']) && $location['uid']) {
            $id = $location['uid'];
            $location['key'] = 'uid';
          }
          elseif (isset($location['tid']) && $location['tid']) {
            $id = $location['tid'];
            $location['key'] = 'tid';
          }
          elseif (isset($location['cid']) && $location['cid']) {
            $id = $location['cid'];
            $location['key'] = 'cid';
          }
          $name = htmlspecialchars_decode(isset($location['name']) ? strip_tags($location['name']) : strip_tags($location['title']), ENT_QUOTES);
          $latlons[] = array(
            $location['latitude'],
            $location['longitude'],
            $id,
            $name,
            $location['marker'],
            $location['key'],
            '',
            '',
          );
          $ct++;
        }
      }
    }
    if ($ct < 2) {
      unset($minmaxes);
      $minmaxes = '';
    }
  }

  ////////////////////////////////
  getlocations_js_settings_do($getlocations_defaults, $latlons, $minmaxes, $mapid, FALSE, $getlocations_defaults['extcontrol']);
  $map = theme('getlocations_show', array(
    'width' => $getlocations_defaults['width'],
    'height' => $getlocations_defaults['height'],
    'defaults' => $getlocations_defaults,
    'mapid' => $mapid,
    'latlons' => $latlons,
    'minmaxes' => $minmaxes,
    'entity_info' => '',
    'object' => '',
  ));
  return array(
    'map' => $map,
    'mapid' => $mapid,
  );
}