我的网站中有以下必应地图代码。它遵循http://www.bingmapsportal.com/isdk/ajaxv7#Infobox20上给出的示例。但是 infoboxOptions 中的 htmlContent 属性和 setHtmlContent() 方法似乎都没有为信息框添加我想要的背景颜色。信息框本身可以正确呈现。其他属性似乎也有效。
$(document).ready(function () {
var map = null;
function getMap() {
// Get the Map
var map = new Microsoft.Maps.Map(document.getElementById('mapDiv'),
{
credentials: "Bing Maps Key",
center: new Microsoft.Maps.Location(42, -120.5),
mapTypeId: Microsoft.Maps.MapTypeId.road,
zoom: 4
});
// Specify InfoBoxOptions
var infoboxOptions = {
showPointer: false,
showCloseButton: false,
width: 500, height: 700,
title: 'Results',
offset: new Microsoft.Maps.Point(-900, -400),
htmlContent: '<div style="background-color:red; width:500px; height:700px;"></div>',
visible: true
};
var defaultInfobox = new Microsoft.Maps.Infobox(map.getCenter(), infoboxOptions);
map.entities.push(defaultInfobox);
defaultInfobox.setHtmlContent('<div style="background-color:red; min-width:500px; min-height:700px;"></div>');
}
getMap();
});
如何将我的 HTML 添加到信息框?我在这里使用了背景颜色,但我的想法是我将显示一个可能有多个点击事件的自定义 HTML。