Javascript Bing地图在视图更改时隐藏信息框
我正在使用Bing地图来显示一些由用户创建的Javascript Bing地图在视图更改时隐藏信息框,javascript,reactjs,bing-maps,Javascript,Reactjs,Bing Maps,我正在使用Bing地图来显示一些由用户创建的图钉和信息框,它工作正常。但是,当用户在视图之间切换时,例如从道路视图切换到卫星视图或鸟瞰视图时,打开的信息框将消失。我有没有办法处理这个事件并保持infobox打开?下面是一些代码 //For showing location const showLocation = (location, onInfoBoxClick, pushpinClick) => { clearTimeout(timeoutHandler); hideInfobox(
图钉
和信息框
,它工作正常。但是,当用户在视图之间切换时,例如从道路视图
切换到卫星视图
或鸟瞰视图
时,打开的信息框
将消失。我有没有办法处理这个事件并保持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}
你试过什么?我们需要看一些代码。查看你能显示你如何将图钉添加到地图的代码吗?当前的Bing地图web控件都没有这样做。你用的是什么版本?你试过什么?我们需要看一些代码。查看你能显示你如何将图钉添加到地图的代码吗?当前的Bing地图web控件都没有这样做。你用的是什么版本?