The marker action for my map is set for open link. Yet when you click on the marker, an info window tries to open (see image). It never fully opens. Ultimately you are directed to the node. Any clues to what might be causing this? I disabled caching, but the problem persists. Thanks for this outstanding module.

Comments

electricmonk’s picture

This happens because of this code block:

  // 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) {
      $map['markers'][$i]['text'] = '<div class="gmap-popup">' . $marker['text'] . '</div>';
    }
  }

As you can see, bdragon has noted that there's a problem there. However, no on seems to have solved this yet. bec? bdragon? I'm reluctant to touch anything myself as this module is kinda complicated, structure-wise.

bwv’s picture

Apologies, I had not seen this... thanks for pointing it out.

ñull’s picture

Status: Needs review » Active
StatusFileSize
new857 bytes

I did not do what bdragon requested, because this is already theme code or I simply don't understand what he means.

But I think I found a fix for the bug. Replace the code in #1 with my code and it should work fine:

  // 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 ($map['markermode']==1) {
      $map['markers'][$i]['text'] = '<div class="gmap-popup">' . $marker['text'] . '</div>';
      }
    }
  }

The thing is that the pop up class was added no matter what. Now it is only added when it should.

ñull’s picture

Status: Active » Needs review
ñull’s picture

Status: Active » Needs review
StatusFileSize
new748 bytes

Reviewing my own fix I realise that the marker mode is valid for all markers so there is no need to check inside the loop.

  // 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']) && $map['markermode']==1) {
    foreach ($map['markers'] as $i => $marker) {
         $map['markers'][$i]['text'] = '<div class="gmap-popup">' . $marker['text'] . '</div>';
    }
  }

Both will work but this last one is better.

ñull’s picture

Category: support » bug
electricmonk’s picture

But this still inserts theming-related code into a business-logic related code, which is a no-no IMO :)

j0rd’s picture

I'm always receiving black infowindows aka. popups when I click on the markers. Does anyone else have this issue as well?

I believe it's because of bad code in theme_gmap (or something that passes the args into it).

Here's the code in the module

  // 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) {
      $map['markers'][$i]['text'] = '<div class="gmap-popup">' . $marker['text'] . '</div>';
    }
  }

But if you do a dpm() in that's foreach($maps['markers']) you'll notice that $marker['text'] is never set.

Instead you can find the value for the title in $marker['opts']['title'];

This function is also not respecting the theme_gmap_location_infowindow_node theme override as mention in THEMEING.txt

So this code should look like this

  // 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) {
      $map['markers'][$i]['text'] = '<div class="gmap-popup">' . $marker['opts']['title'] . '</div>';
    }
  }

Or more precisely gmap_location.module should get getting the info window HTML from gmap_location_infowindow_node as the documentation reads.

shushu’s picture

I got into the same piece of code, with a different problem.
I wanted the marker to just "redirect" to another url. marker.js won't make it happen as long as the marker has a 'text' field.

I think com2's patch is ok, but I will add:
if (isset($marker['text'] ))
before setting anything...

electricmonk, it is true that this is not the right place for it, but I think we rather fix the bug as is, since the code is already there in 6.x-1.1-rc1.

Regarding to my own problem, I will send my patch to gmap_location.module for adding marker mode in the block map.

droope123’s picture

Status: Needs review » Active

Hi.

This issue is not nearly solved, needs to be fixed.

For those wanting to add some stuff to the bubble, and are in need to get this working NOW, here is how I did it.

This code, in gmap.module (line 882)

<?php
  // 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) {
      $map['markers'][$i]['text'] = '<div class="gmap-popup">' . $marker['text'] . '</div>';
    }
  }
?>

Would go to this =>

 <?php  // 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 ($marker['text']) {
			$map['markers'][$i]['text'] = '<div class="gmap-popup">' . $marker['text'] . '</div>';
		}
		else {
//if god knows why we don't have text, then let's make things work the bad way. 
			$map['markers'][$i]['text'] = '<div class="gmap-popup"><div class="gmap-title">' . $marker['opts']['title'] .'</div><div class="gmap-street">'. $marker['opts']['street']. '</div><div class="gmap-phone">' . $marker['opts']['phone'] . '</div></div>';
		}
    }
  }?>

Those variables ($marker['opts']['phone']) aren't defined by default, so you have to go to gmap_location.module and set them yourselves.

gmap_location.module (line 678)

        $markers[] = array(
          'latitude' => $loc['latitude'],
          'longitude' => $loc['longitude'],
          'markername' => $markername,
          'offset' => $count-1,
          'opts' => array('title' => $markertitle),
        );
        

goes to:

        $markers[] = array(
          'latitude' => $loc['latitude'],
          'longitude' => $loc['longitude'],
          'markername' => $markername,
          'offset' => $count-1,
          'opts' => array('title' => $markertitle, 'street' => $node->locations[0]['street'], 'phone' => $node->locations[0]['phone']),
        );

Add an "echo print_r($node);" somewhere to know what data you can add.

Cheers!
Droope

bdragon’s picture

Temporary fix committed.
http://drupal.org/cvs?commit=296358
http://drupal.org/cvs?commit=296360

  From #452316: Click marker anomoly (image attached):
  Stop confusing the marker system by blindly wrapping marker.text in a div, even
  if it didn't exist.

This should enable the other marker modes to work as intended. (See js/marker.js starting at // Default marker actions. to see how this all works on the JS side.)

johnv’s picture

Status: Active » Closed (fixed)

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