最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - title of a marker of google map marker API - Stack Overflow

programmeradmin1浏览0评论

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
Add a comment  | 

2 Answers 2

Reset to default 11

you 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).

发布评论

评论列表(0)

  1. 暂无评论