Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  




           


Re: Bing Maps InfoBox getting Cut Off if near edge of Map
> View Original Message
Variation 2:
If you are using mouseover on pin to show the infobox, you may want the infobox to completely overlap the pin, so that you can leave the infobox (and thereby remove the infobox on mouse out), without passing over the pin and showing it again.

To do this, just shift the box a bit more to cover the pin. I then had to change the Y position of top-left quadrant so that the 'close' button isn't on top of the pin (which would show the infobox again as soon as it is closed since your mouse is over it)

// set correct position of infobox so it shows on the map
var mapQuadrantWidth = myVEMap.getWidth() / 2;
var infoWidth = lastBox.getWidth();
var infoHeight = lastBox.getHeight();

// if you wanted you could also optimize for height, but my infoboxes are too tall to matter
//var mapQuadrantHeight = myVEMap.getHeight() / 2;
var infoHeight = lastBox.getHeight(); // dynamic because of auto in stylesheet on control
var shift = pin.getWidth(); // cover pin to help with mouseover

var point = myVEMap.tryLocationToPixel(lastBox.getLocation());
if (point.x > 0 && point.y < 0) { // your box is in the top right quadrant.
lastBox.setOptions({ offset: new Microsoft.Maps.Point(infoWidth * -1 + shift, (infoHeight * -1) + (pin.getHeight() * 3)) }); // show box lined just above top of pin (for easier mouse over to box), and above so that close btn isn't over original pin
}
else if (point.y < 0) { // your box is in the top left quadrant
lastBox.setOptions({ offset: new Microsoft.Maps.Point(shift*-1, (infoHeight * -1) + pin.getHeight()) }); // show box lined with top of pin (for easier mouse over to box)
}
else if (point.x + infoWidth > mapQuadrantWidth) { // your box is in the bottom right quadrant
lastBox.setOptions({ offset: new Microsoft.Maps.Point(infoWidth * -1 + shift, 0) }); // show box
}
else { // your box is in the bottom left quadrant
lastBox.setOptions({ offset: new Microsoft.Maps.Point(shift*-1, 0) }); // show box
}

Created By: amos 3/21/2014 12:19:51 PM