As I have seen on other websites created with Google Maps, there must be an option in the Google API to expand a marker by default. By default, you would not only see a red inverted raindrop, but also a full text box that pop-ups when you normally click on the marker.

In the Gmap documentation it is mentioned that there are more commands available in the gmap module parser. These commands seem not to be documented on Drupal.org. My request could then be interpreted in two ways.

1. Create an overview of additional commands and options that Gmap module users can manually add to the Gmap macro.

2. When using the Google Map Macro Editor, add the option 'Points (expanded by default)' to the drop-down menu under 'What happens when you click on the map:'. That way the user can easily differentiate between creating closed and expanded markers.

Comments

webgeer’s picture

1. The features are relatively well documented on http://webgeer.com/gmapdemo (although this includes documenting a number of xmaps features which are no longer supported). If someone wants to create a page a drupal.org that would be fine with me.

2. The macro creator needs quite a bit of updating. I don't really have time to do it right now, but what I would like to see is that when you click on a marker an info window opens and gives you a textbox to enter the html that you want to have appear in the info window when clicked and gives you a drop down menu of icons you can change it to. I would also like to add some more editing features for lines (remove last point, change color, change thickness, change opacity). None of this is that difficult to do, would just take a little bit of time...

mango’s picture

I have studied the documentation page you refer to (http://webgeer.com/gmapdemo) before submitting my request. Unfortunately, there is no mention of expanding markers by default. I cannot find information about the parser either, so my options to investigate this issue end there.

webgeer’s picture

Component: User interface » Documentation

I'm not sure what you mean by "expanding markers".

If you mean opening an info window, then it can be seen on that page. click on marker to see what is in a window and then look at the macro that was created to see how that was inserted. This is referred to as a "text popup" on that page. If you mean the ability to have the info window opened automatically when the page is opened without clicking, that does not exist. It could be done, but I'm not sure what the best way of adding that to the macro is.

mango’s picture

If you mean the ability to have the info window opened automatically when the page is opened without clicking, that does not exist. It could be done, but I'm not sure what the best way of adding that to the macro is.

That is what I meant: to have certain "text popups" open (or popup) by default. For example, on page http://webgeer.com/gmapdemo, if you click on marker number 1 the text popup shows "Kits pool". I would like to set up a gmap so that the text popup is displayed by default for particular markers of my choice.

webgeer’s picture

Any thoughts on how you think it should work from a user perspective?

I will add this ability for the associative array. I think it could also be added for the macro, but I'm not sure what would be the best way of doing it. One idea I have if the text starts with a "*" then it will do that as an open window. However, if you have any other ideas on ways to do it I could consider that too.

Joe D’s picture

Version: 6.x-1.x-dev » 4.7.x-1.x-dev

Is there a way to control the size of the text box popup for a marker and/or the position where it pops up relative to the marker?
I want to make the box smaller and have it pop up below the marker.
Thanks

webgeer’s picture

The size of the marker can be set be setting the width for the style .gmap-popup. You can edit the gmap.css file to do this. However, this only lets you set one width for all of the pop-up windows. Alternatively, if you are writing a module or creating the associative array some other way, you can set the width by defining the marker item map[markers][]['win-width']='200px'

I know of no way of making Google open the window below the marker. I think that it may be possible with a third party script, but I would prefer to keep as much of the code using the Google API as possible.

Both of these concepts are too complicated to ever be included as part of the macro.

bdragon’s picture

Version: 4.7.x-1.x-dev » 5.x-1.x-dev
Status: Active » Fixed

I'm working on closing bugs at the moment.

In any case, the 5.x version has had "expand by default" capability for a while now, but it wasn't exposed to the macro. I just (as of about a minute ago) extended the macro syntax like so (wait for the next snapshot or try latest DRUPAL-5 from CVS to experiment with it:)

[gmap |markers=big blue::40.713955826286046,-5.9765625%autoclick:I am a Popup]

After the coordinates of a marker and before the optional :, you can put tokens in. Currently the only one supported is "autoclick", which will make a marker act like it was clicked as soon as the map loads.

Anonymous’s picture

Status: Fixed » Closed (fixed)
afagioli’s picture

if you're on dr5, try

$markers[] =       Array(
        'autoclick' => true  ,
      );

dwatts3624’s picture

Version: 5.x-1.x-dev » 6.x-1.1
Category: feature » support

augustofagioli, I am getting better at Drupal but still am very new to overriding variables.

Would you be able to lend any advice on where to set that? Would I make a custom module or add it into the template.php file?

Really, all I'm trying to do it get the info window to autoclick on a CCK location field. I can set my macro in the field settings; however, bdragon's solution doesn't seem to work because the lat & long is set by the field not the macro.

Any ideas?

I've also tried using JS to manually make this happen.

skh’s picture

I too needed the info window of the first result to auto-open. After some digging, found a couple of ways to do it.

#1: function template_preprocess_gmap_view_gmap in gmap.views.inc

Override in your template.php, and:

function MYTHEME_preprocess_gmap_view_gmap(&$vars) {
  $vars['map_object']['markers'][0]['autoclick'] = TRUE;
  $vars['map'] = theme('gmap', array('#settings' => $vars['map_object']));
}

Drawbacks: ends up building the map element twice.

#2: function theme_gmap($element) in gmap.module

Override in your template.php, and

function MYTHEME_gmap($element) {
    $element['#settings']['markers'][0]['autoclick'] = TRUE;
    //... rest of theme_gmap function (copy + paste original)

Drawbacks: requires an identical theme_gmap function with one line change. I guess you could call theme_gmap directly instead.

Note: ['markers'][0] is the first result, you could set any of them to open automatically.

kevinchampion’s picture

If you build the map using a map array, which you can then plug into theme_gmap, you simply set the 'options' parameter of the marker whose info window you'd like to be automatically opened to contain the property 'autoclick' => true. It looks something like this:

$map_array1 = array(
    'width' => "700px",        // map width in pixels or %
    'height' => "500px",      // map height in pixels
    'markers' => array(
      array(
        'text' => $title,
        'latitude' => $location[latitude],
        'longitude' => $location[longitude],
        'options' => array('autoclick' => true),
      ),
    ),
  );
  print theme('gmap', array('#settings' => $map_array1)); 
summit’s picture

Status: Closed (fixed) » Active

I do not think this is fixed, because it is not module based possible. I set it to active again if thats ok.
If I am incorrect in this, I apologize.

For D7 there is this issue, may be this is the solution?
http://drupal.org/node/1377908

greetings, Martijn

coderider’s picture

Status: Closed (fixed) » Fixed

i find a way to set gmap marker on autoclick i am useing this template function at my project site it works fine
copy hole function theme_gmap from gmap.module line/935 and past in to you template.php
rename it THEME_gmap.
and add this line

$map['markers'][0]['autoclick'] = TRUE;
just after this line

 if (isset($marker['text'])) {
         //here place this line 
        $map['markers'][0]['autoclick'] = TRUE;

hole edited function check below
just copy and past and rename to your theme

/**
 * Gmap element theme hook
 */
function THEME_gmap($variables) {
  $element = $variables['element'];

  // Track the mapids we've used already.
  static $mapids = array();

  _gmap_doheader();

  $mapid = FALSE;
  if (isset($element['#map']) && $element['#map']) {
    // The default mapid is #map.
    $mapid = $element['#map'];
  }
  if (isset($element['#gmap_settings']['id'])) {
    // Settings overrides it.
    $mapid = $element['#gmap_settings']['id'];
  }
  if (!$mapid) {
    // Hmm, no mapid. Generate one.
    $mapid = gmap_get_auto_mapid();
  }
  // Push the mapid back into #map.
  $element['#map'] = $mapid;

  gmap_widget_setup($element, 'gmap', $mapid);

  if (!isset($element['#gmap_settings'])) {
    $element['#gmap_settings'] = array();
  }

  // Push the mapid back into #gmap_settings.
  $element['#gmap_settings']['id'] = $mapid;

  $mapdefaults = gmap_defaults();
  $map = array_merge($mapdefaults, $element['#gmap_settings']);
  
  
  // Styles is a subarray.
  if (isset($element['#gmap_settings']['styles'])) {
    $map['styles'] = array_merge($mapdefaults['styles'], $element['#gmap_settings']['styles']);
  }
  gmap_map_cleanup($map);

  // Add a class around map bubble contents.
  // @@@ Bdragon sez: Becw, this doesn't belong here. Theming needs to get fixed instead..
  if (isset($map['markers'])) {
    foreach ($map['markers'] as $i => $marker) {
      if (isset($marker['text'])) {
        $map['markers'][0]['autoclick'] = TRUE;//newly add  this is line should active autoclick  
        $map['markers'][$i]['text'] = '<div class="gmap-popup">' . $marker['text'] . '</div>';
      }
    }
  }

  switch (strtolower($map['align'])) {
    case 'left':
      $element['#attributes']['class'][] = 'gmap-left';
      break;
    case 'right':
      $element['#attributes']['class'][] = 'gmap-right';
      break;
    case 'center':
    case 'centre':
      $element['#attributes']['class'][] = 'gmap-center';
  }

  $style = array();
  $style[] = 'width: ' . $map['width'];
  $style[] = 'height: ' . $map['height'];

  $element['#attributes']['class'] = array_merge($element['#attributes']['class'], array('gmap', 'gmap-map', 'gmap-' . $mapid . '-gmap'));

  // Some markup parsers (IE) don't handle empty inners well. Use the space to let users know javascript is required.
  // @@@ Bevan sez: Google static maps could be useful here.
  // @@@ Bdragon sez: Yeah, would be nice, but hard to guarantee functionality. Not everyone uses the static markerloader.
  $o = '<div style="' . implode('; ', $style) . ';" id="' . $element['#id'] . '"' . drupal_attributes($element['#attributes']) . '>' . t('Javascript is required to view this map.') . '</div>';

  gmap_module_invoke('pre_theme_map', $map);

  if (isset($mapids[$element['#map']])) {
    drupal_set_message(t('Duplicate map detected! GMap does not support multiplexing maps onto one MapID! GMap MapID: %mapid', array('%mapid' => $element['#map'])), 'error');
    // Return the div anyway. All but one map for a given id will be a graymap,
    // because obj.map gets stomped when trying to multiplex maps!
    return $o;
  }
  $mapids[$element['#map']] = TRUE;

  // Put map data in a setting.
  drupal_add_js(array('gmap' => array($element['#map'] => $map)), 'setting');

  return $o;
}

hope now this issue is fixed
coderider

Version: 6.x-1.1 » 7.x-1.0-beta1
Assigned: Unassigned » coderider
Status: Active » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jordan8037310’s picture

Status: Fixed » Closed (fixed)
StatusFileSize
new583.22 KB

Thanks for this Coderider! Really helps. Just wondering, but did you happen to know of a way to center the map based on the fact that the info window is now displayed?

Usually when you "click" on a location and get the info window, the viewing area automatically moves to include the window. My view is a bit limited in height, but I was wondering if you had to deal with this as well.

Screen Shot 2013-02-19 at 2.00.00 PM.png