添加指向Google地图信息的超链接。窗口

时间:2015-10-06 14:01:58

标签: javascript jquery google-maps google-maps-api-3 hyperlink

我正在创建一个包含多个标记的Google地图。每个标记显示一个信息。点击时的窗口。我需要弄清楚如何添加信息的超链接。窗口通过Javascript。

以下是确定将在信息中显示哪些文本的Javascript示例。窗口:

"infoWindows": [{
            "id": 4980,
            "marker_id": "latitude and longitude here",
            "title": "title here",
            "subtitle": "subtitle here",
            "phone": "phone here",
            "address": "address here",
            "email": "email here",
            "web": "web here",
            "content": "content here",
            "open": 0
        }

以下是允许在点击标记时显示此信息的Javascript:

b.settings.infoWindows[j].title.length > 0 && (l += '<div class="uber-google-maps-info-window-field uber-google-maps-title">' + b.settings.infoWindows[j].title + "</div>"), 

b.settings.infoWindows[j].subtitle.length > 0 && (l += '<div class="uber-google-maps-info-window-field uber-google-maps-subtitle">' + b.settings.infoWindows[j].subtitle + "</div>"),  

b.settings.infoWindows[j].phone.length > 0 && (l += '<div class="uber-google-maps-info-window-field">' + b.settings.infoWindows[j].phone + "</div>"),  

b.settings.infoWindows[j].email.length > 0 && (l += '<div class="uber-google-maps-info-window-field">' + b.settings.infoWindows[j].email + "</div>"), 

b.settings.infoWindows[j].address.length > 0 && (l += '<div class="uber-google-maps-info-window-field">' + b.settings.infoWindows[j].address + "</div>"), 

b.settings.infoWindows[j].web.length > 0 && (l += '<div class="uber-google-maps-info-window-field uber-google-maps-web">' + b.settings.infoWindows[j].web + "</div>"), 

b.settings.infoWindows[j].content.length > 0 && (l += b.settings.infoWindows[j].content), l += "</div>";

如何添加此信息的超链接。气泡?我不确定如何在Javascript中格式化超链接。我希望将超链接添加到&#34; web&#34;部分信息。窗口。非常感谢!

1 个答案:

答案 0 :(得分:1)

假设您要将电子邮件添加为超链接...

'<div class="uber-google-maps-info-window-field"><a href="mailto:' + b.settings.infoWindows[j].email + '">' + b.settings.infoWindows[j].email + '</a></div>'

或其他一些超链接

'<div class="uber-google-maps-info-window-field"><a href="' + b.settings.infoWindows[j].someHyperlink + '">' + b.settings.infoWindows[j].someHyperlink + '</a></div>'