You are here

function getlocations_usermap in Get Locations 6

Same name and namespace in other branches
  1. 6.2 getlocations.module \getlocations_usermap()
  2. 7 getlocations.module \getlocations_usermap()

Menu callback

Parameters

int $uid:

Return value

Returns a map of locations of a user

1 call to getlocations_usermap()
getlocations_box in ./getlocations.module
1 string reference to 'getlocations_usermap'
getlocations_menu in ./getlocations.module
Implementation of hook_menu().

File

./getlocations.module, line 274
Displays locations on a map. for Drupal 6 using version 3 googlemaps API

Code

function getlocations_usermap($uid) {
  if (module_exists('location_user')) {
    $getlocations_defaults = getlocations_defaults();
    $marker = $getlocations_defaults['user_map_marker'];
    $locations = getlocations_load_locations($uid, 'uid');
    $account = user_load(array(
      'uid' => $uid,
    ));
    $latlons = array();
    $minmaxes = array(
      'minlat' => 0,
      'minlon' => 0,
      'maxlat' => 0,
      'maxlon' => 0,
    );
    $ct = 0;
    if (count($locations)) {

      // we should loop over them and dump bummers with no lat/lon
      foreach ($locations as $key => $location) {
        if (getlocations_latlon_check($location['latitude'] . ',' . $location['longitude'])) {
          $minmaxes = getlocations_do_minmaxes($ct, $location, $minmaxes);
          if (!isset($location['key'])) {
            $location['key'] = '';
          }
          else {
            $location['lid'] = $uid;
          }

          // per location marker
          if (isset($location['marker']) && !empty($location['marker'])) {
            $marker = $location['marker'];
          }
          $ct++;
          $name = htmlspecialchars_decode($location['name'] ? strip_tags($location['name']) : strip_tags($account->name), ENT_QUOTES);
          $latlons[] = array(
            $location['latitude'],
            $location['longitude'],
            $location['lid'],
            $name,
            $marker,
            $location['key'],
          );
        }
      }
    }
    if ($ct < 2) {
      unset($minmaxes);
      $minmaxes = '';
    }
    drupal_set_title(t('View user @t locations', array(
      '@t' => $account->name,
    )));
    return getlocations_setlocations($latlons, $minmaxes, 'user', $account);
  }
}