我正在使用Bing地图显示用户创建的一些pushpins
和infoboxes
,并且它正常运行。但是,当用户在视图之间切换时,例如从infobox
切换到Road view
或satellite
时,打开的Bird's eye
会消失。有什么方法可以处理该事件并保持infobox
开放吗?下面是一些代码
//For showing location
const showLocation = (location, onInfoBoxClick, pushpinClick) => {
clearTimeout(timeoutHandler);
hideInfobox();
const latVal = location.get('lat');
const longVal = location.get('long');
const locationId = location.get('id');
const pinLocation = new Microsoft.Maps.Location(latVal, longVal);
const infoBoxContainer = document.getElementById('infoBoxContainer');
const offsetWidth = infoBoxContainer.offsetWidth;
const offsetHeight = infoBoxContainer.offsetHeight;
const pushpinInfoBoxHolder = document.createElement('div');
pushpinInfoBoxHolder.id = 'pushpinInfoBoxHolder';
pushpinInfoBoxHolder.style.width = offsetWidth + 'px';
pushpinInfoBoxHolder.style.height = offsetHeight + 'px';
const infoBoxHTML = infoBoxContainer.innerHTML;
const pinInfoBox = new Microsoft.Maps.Infobox(
pinLocation,
{
visible: true,
htmlContent: pushpinInfoBoxHolder.outerHTML,
// the infobox needs to be shifted just a slight bit more than half it's width,
// hence the X cordinate value, The Y co-ordinate value is a number arrived by
// trial and is constant
offset: new Microsoft.Maps.Point(-(offsetWidth / 2 + 2), 58)
}
);
我尝试用下面的处理程序捕获事件但没有成功
Microsoft.Maps.Events.addHandler(map, 'viewchangeend', () => {//showinfobox function}