Text fields used as tooltip are encoded in HTML and should not.
Here is an example:

character : &
in generated HTML source code : \x26amp;
displayed : &

It should be:

character : &
in generated HTML source code : \x26
displayed : &

Comments

xmarket’s picture

Can you provide more details?

srobert72’s picture

I have a title that contains '&' character : golf & spa hotel
In GMaps map tooltip, it appears : golf & spa hotel

If I check HTML source code it is writen : "title": "golf \x26amp; spa hotel"
Correct HTML would be : "title": "golf \x26 spa hotel"

I think title is first encoded in HTML :
golf & spa hotel becomes golf & spa hotel
then it is encoded for JQuery :
golf & spa hotel becomes golf \x26amp; spa hotel

First conversion is not necesssary.
We must give tooltip brut text as it is set in node edit form :
golf & spa hotel would become golf \x26 spa hotel

srobert72’s picture

I don't know if problem is really here but it must be something like this :

file : gmaps.static-map-pages.inc
line : 458

  if (!empty($marker->title)) {
    $marker->title = check_plain($marker->title);
  }

check_plain() will encode text in HTML format.

xmarket’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

summit’s picture

Issue summary: View changes

Hi,
Thanks. This worked also in D7!
Thanks for sharing.
greetings, Martijn

stephen ollman’s picture

@Summit, when you say it works in D7 as well, what module and file are you referring to?

stephen ollman’s picture

Found the D7 file to edit: gmap_plugin_style_gmap.inc

However the check_plain() function didn't work on either the $tooltip variable or on $marker->title .

The apostrophe in the tooltip title is still showing as ' and the ampersand as &

What I did add to the file is the following to cover both and apostrophe and an ampersand.

if(strpos($tooltip, ''') !== false) {
    $tooltip = str_replace("'","'",$tooltip);
}
if(strpos($tooltip, '&') !== false) {
    $tooltip = str_replace("&","&",$tooltip);
}

This was added prior to:

$marker = array(
            'latitude' => $lat,
            'longitude' => $lon,
            'markername' => $markername,
            'offset' => $offsets[$markername],
            'text' => $bubbletext,
            'autoclick' => (!empty($autoclick_nid) && !empty($row_nid) && $autoclick_nid == $row_nid) ? 1 : 0,
            'opts' => array(
              'title' => $tooltip,
              'highlight' => (!empty($highlight_nid) && !empty($row_nid) && $highlight_nid == $row_nid) ? 1 : 0,
              'highlightcolor' => $this->options['highlight_nodearg_color'],
              'animation' => $this->options['animation'],
            ),
          );

Certainly open to a better, cleaner solution.