当视图发生变化时,Bing贴图会隐藏信息框

时间:2016-05-18 20:30:43

标签: javascript reactjs bing-maps

我正在使用Bing地图显示用户创建的一些pushpinsinfoboxes,并且它正常运行。但是,当用户在视图之间切换时,例如从infobox切换到Road viewsatellite时,打开的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}

0 个答案:

没有答案