I try to change the color of part of the title, but look like the title option does not take html format. How can I make it work?
Thank you
var testtitle = '<font color="green">This is some text!</font> another text';
var marker = new google.maps.Marker({
position: location,
title: testtitle,
map: map
});
I try to change the color of part of the title, but look like the title option does not take html format. How can I make it work?
Thank you
var testtitle = '<font color="green">This is some text!</font> another text';
var marker = new google.maps.Marker({
position: location,
title: testtitle,
map: map
});
Share
Improve this question
edited Oct 9, 2013 at 18:03
shiro
asked Oct 9, 2013 at 17:52
shiroshiro
2552 gold badges7 silver badges20 bronze badges
2 Answers
Reset to default 11you must use InfoWindow object
see this doc google map api
var infowindow = new google.maps.InfoWindow({
content: "<span>any html goes here</span>"
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Uluru (Ayers Rock)'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
A "title" is a tooltip that is automatically created for the google.maps.Marker object. It doesn't support HTML markup. If you want to create one that is different from the default, you can, but it would be custom.
See this post for one custom tool tip option (a google search found 2 posts describing them).