views:

92

answers:

4

Say I have this piece of code:

var marker = new google.maps.Marker({
    position: location,
    title: 'Búfals',
    map: map
});

This creates a marker as expected but if I hover the mouse over it I don’t see 'Búfals'
as I would expect (instead I see the html code).

This doesn't make any difference:

var marker = new google.maps.Marker({
    position: location,
    title: unescape('Búfals'),
    map: map
});  

Any ideas?

Thanks.

A: 

You may want to use:

var marker = new google.maps.Marker({
   position: myLatlng,
   map: map,
   title: unescape('B%FAfals')
});
Daniel Vassallo
Thanks Daniel. Yes this works but what is this code '%FA'?
Anthony
@Anthony: It is called Percent Encoding (http://en.wikipedia.org/wiki/Percent-encoding). This is a chart of the ASCII characters with this encoding: http://i-technica.com/whitestuff/urlencodechart.html. The JavaScript `unescape()` function returns the ASCII string for the specified encoding value.
Daniel Vassallo
I see. Thanks Daniel. The thing is I can't really use this solution as the string I use is html encoded (not percent encoded). At least I understand why escape didn't work.
Anthony
A: 

Similar to what Daniel suggested, you could try using the unicode value for the character you're trying to display, in your case it would be \u09fa.

hora
A: 

This may be an overkill but it works:

function decode(txt){
  var sp = document.createElement('span');
  sp.innerHTML = txt;
  return sp.innerHTML;
}

decode('Búfals')
Mic
A: 

@Mic unescape() did not work for me too.. Your solution fixed my problem. Thanks..

agas