Looks like for some reason e.target is not part of the displayInfobox function.
I changed your code a bit to 2, 3 places to get something close to your intended point. Please check it below:
var map = null; var dataLayer = null; var infoboxLayer = null; function loadMap() { //Prep default location var defaultLocation = new Microsoft.Maps.Location(53.6880, -2.6646); //Prep Map Options var mapOptions = { //credentials: 'KEY_REMOVED', center: defaultLocation, mapTypeId: Microsoft.Maps.MapTypeId.road, zoom: 7, enableClickableLogo: false, enableSearchLogo: false } //Initialise the primary map control map = new Microsoft.Maps.Map(document.getElementById('BobElliotMap'), mapOptions); //Add data layer dataLayer = new Microsoft.Maps.EntityCollection(); map.entities.push(dataLayer); // Add infobox layer infoboxLayer = new Microsoft.Maps.EntityCollection(); map.entities.push(infoboxLayer); //Prep InfoBox & add to infobox layer var infoboxOptions = { width: 300, height: 200, visible: false, offset: new Microsoft.Maps.Point(0, 20) }; infobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), infoboxOptions); infoboxLayer.push(infobox); //Add Data to the map DrawPins(); setTimeout(function() { //Initial zoom for testing zoomMap function var pushpin = dataLayer.get(0); var indx = dataLayer.indexOf(pushpin); zoomMap(indx, pushpin.getLocation().latitude, pushpin.getLocation().longitude); },500); } function displayInfobox(e) { if ( this.target.id && this.target.id.indexOf("pin") != -1 ) { alert("click event fired on pushpin"); infobox.setOptions({ title: this.target.Title, description: this.target.Description, visible: true, offset: new Microsoft.Maps.Point(0, 25) }); infobox.setLocation(this.target.getLocation()); //A buffer limit to use to specify the infobox must be away from the edges of the map. var buffer = 30; var infoboxOffset = infobox.getOffset(); var infoboxAnchor = infobox.getAnchor(); var infoboxLocation = map.tryLocationToPixel(this.target.getLocation(), Microsoft.Maps.PixelReference.control); var dx = infoboxLocation.x + infoboxOffset.x - infoboxAnchor.x; var dy = infoboxLocation.y - 25 - infoboxAnchor.y; if (dy < buffer) { //Infobox overlaps with top of map. //
source share