I' admin'ing an interactive website where users can set their location (a single location) and also submit nodes.

Different users are in different places in the country. I've had several requests to default the map to the location the user has submitted as their own location - so they see more local stuff.

Is there a way to theme or override the default location of the map to default to the user's location? I'm not too familiar with this module, having taken over the administration of the above website while a friend is sick, but pretty comfortable with themeing other parts of Drupal. A pointer to the function to override/change would be all that's needed.

Many thanks for your attention.

Comments

farald’s picture

I find this *VERY* interesting as Im starting on a site meant to be used worldwide.
It would be annoying to zoom the map all the way in over and over and over again:)

jarodms’s picture

For starters...GMap...great module and kudos to the developers!

I could really use this functionality too!!! I couldn't find any additional posts on this and am wondering if anyone is looking into this. If not I'll start looking at the code, but no guarantees from me. ;) Thanks!

farald’s picture

Category: support » feature
TechnoBuddhist’s picture

Hi,

Is this as simple as... gmap_location.module - function gmap_location_node_page()

...

  // Special stuff for single marker
  if ($count == 1) {
    // Center map on only marker.
    $map['latitude'] = $map['markers'][0]['latitude'];
    $map['longitude'] = $map['markers'][0]['longitude'];

    // Autoclick in single marker case.
    if ($mode == 1) {
      $map['markers'][0]['autoclick'] = TRUE;
    }
  } else {
    // This will center the map around the current user
    global $user;
    $user_loc = location_load_locations($user->uid, 'uid');
    if (!empty($user_loc)) {
      $map['latitude'] = $user_loc[0]['latitude'];
      $map['longitude'] = $user_loc[0]['longitude'];
    }
  }

...

The change is obviously adding the else clause when not looking at a single node. This works for me, but I only allow a single user location, hence the $user_loc[0].

If user location is empty then the default location is left as set in gmap admin config.

Interesting to hear a response from others, can't believe it's that simple and has been an issue for over a year now.

Be nice I spose to have a checkbox in admin that says "center on user?", but that above works for me in my setup.

johnv’s picture

Status: Active » Closed (won't fix)

Closing this very old issue. Please reopen if it is still valid.