Yes, sorry, I should have just posted my code from the beginning.
%@ Control Language="C#" AutoEventWireup="true" CodeFile="----------.ascx.cs" Inherits="CMSWebParts_-------------" %>
<div ID="myMap<%=MapID%>" style="position:relative; display:inline-block" ></div>
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
<script type="text/javascript">
function GetMap<%=MapID%>() {
//global variables for the map and the infobox
var map = null, infobox = null, myDirections = null, mapID = null;
myDirections = '<%=UseDirections%>';
mapID = "<%=MapID%>";
// Set the map options
var mapOptions = { credentials: "<%=BingMapKey%>",
width: <%=MapWidth%>,
height: <%=MapHeight%>,
center: new Microsoft.Maps.Location(<%=DefaultLatitude%>,<%=DefaultLongitude%>),
zoom: <%=ZoomLevel%>,
enableSearchLogo:false,
showMapTypeSelector:false,
enableClickableLogo:false,
showScalebar:false };
//create the map
map = new Microsoft.Maps.Map(document.getElementById("myMap"+mapID), mapOptions);
// Disable mouse wheel
var noMouseWheel = function (e) { e.handled = true; return true;}
Microsoft.Maps.Events.addHandler(map, 'mousewheel', noMouseWheel);
// Retrieve the location of the map center
var center = map.getCenter();
function pinClick(e)
{
alert(e.target.hoverText);
}
//create js arrays of the long / lat list strings coming from code behind file
var longeArray = "<%= Longitude %>";
longeArray = longeArray.split(",");
var latArray = "<%= Latitude %>";
latArray = latArray.split(",");
var officeNameArray = "<%= OfficeName %>";
officeNameArray = officeNameArray.split(",");
var officeURLArray = "<%= OfficeURL %>";
officeURLArray = officeURLArray.split(",");
var officeDirectionsArray = "<%= OfficeDirections %>";
officeDirectionsArray = officeDirectionsArray.split(",");
//loop through the arrays and create pushpin / infobox for each
var pushpin = [];
var infobox = [];
for(i=0;i<longeArray.length;i++)
{
var latitude = latArray[i], longitude = longeArray[i], docURL = officeURLArray[i], hoverText = officeNameArray[i], directionsURL = officeDirectionsArray[i];
var pushPinOptions = { icon: "-------------------.png" }
pushpin[i] = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(latitude, longitude), pushPinOptions);
pushpin[i].docURL = docURL;
pushpin[i].ID = i + "00" + mapID;
pushpin[i].hoverText = hoverText;
pushpin[i].directions = directionsURL;
var infoboxOptions = { visible: true, title: pushpin[i].ID, offset: new Microsoft.Maps.Point(13, 45), showPointer: false, width:200, height:30 };
infobox[i] = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(latitude,longitude), infoboxOptions);
//attach pins and infoboxes to map
map.entities.push(pushpin[i]);
map.entities.push(infobox[i]);
//event handlers
pushpinClick = Microsoft.Maps.Events.addHandler(pushpin[i], 'click', pinClick);
pushpinMouseOver = Microsoft.Maps.Events.addHandler(pushpin[i], 'mouseover', closeInfobox);
}
function closeInfobox(e)
{
//I can alert stuff about the pins, but that's about it.
//alert(e.target.ID);
}
}
GetMap<%=MapID%>();
</script>
This has changed a lot from the other day. I was just trying a bunch of different things. The original single map code only had a single infobox. The current code feels "spaghetti". I think i'm going to create a plain html outside of visual studio and try to recreate the 2 map scenario in it's most basic form without any dynamic content coming from other places. Again, any suggestions beyond simply finding a solution would be happily received. I am trying to get the task at hand done, but also want to learn from it.