我已经在地图上的国家周围设置了一个带有多边形的地图,并且想要添加一个信息框,以便在悬停时为每个国家显示一些信息。
如果没有多边形,我可以很容易地显示信息框,但是当将它们分配给 PolygonOptions 类时,什么也没有发生。文档说,只要我加载了 Bing 主题模块(我这样做了),信息框就会在悬停和单击时显示。
这方面的文档/示例似乎为零,因此希望各位聪明的人能提供帮助。
这是一些相关的代码;
var center = this.map.getCenter();
// Create an info box
var infoboxOptions = {
width: 300,
height: 100,
title: 'Testing', // sourceItems.data.dataset[0].data[index].key,
description: "Visits: 20", // + sourceItems.data.dataset[0].data[index].visits,
showPointer: true,
titleClickHandler: this.polygonInfo,
offset: new Microsoft.Maps.Point(-100, 0),
typeName: Microsoft.Maps.InfoboxType.mini,
zIndex: 1000
};
var polyinfobox = new Microsoft.Maps.Infobox(center, infoboxOptions);
var polygonOptions = {
fillColor: Microsoft.Maps.Color.fromHex(fillColour),
strokeColor: Microsoft.Maps.Color.fromHex(fillColour),
strokeThickness: 1,
infobox: polyinfobox
};
var result = new Microsoft.Maps.Polygon(vertices, polygonOptions);