Thanks for your help Martin!!!
Here is a rather length snippet of code that should explain what I am trying to do. As you can probably tell, what I am currently doing is providing an ASPX page with a map of Florida. Each of the 8 regions of the map have a polygon area that the user clicks on. When the user clicks on a specific region, a JavaScript function for that specific region, i.e. SE() for the South East region, is called. The JavaScript function reads the information from an XML file for that region (SE_Data.xml). This all works fine. What I need to do is read the current information from a SQL Server database that has data (including Latitude and Longitude) for hotels in the selelected area. I could have the ASP.NET code read the latest data from the database and create an XML file for each region. Considering there are 8 regions, this would take too long. I need to come up with away to read the database after the region is selected by the user. Here is the C# code:
<%@ Page Language="c#" EnableViewState="True" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Web.Security " %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Collections" %>
<%@ import Namespace="System.web.UI.WebControls" %>
<%@ import Namespace="System.Drawing" %>
<script runat=server>
.
.
.
// ASP.NET code to create XML files from Region.dbo SQL Server Database
.
.
.
</script>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script src="http://maps.google.com/maps?file=api&v=2&key=[my google map key]"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
// Load State of Florida Map with message callout
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(28.4565, -81.4676), 6);
var textMessage = "Coming Soon: Official Meetings Maps!";
map.openInfoWindow(map.getCenter(), document.createTextNode(textMessage));
}
}
// Create Google Map point references and markers for each of the 8 regions in the state.
.
.
.
.
.
.
.
function SE() {
this.map = new GMap2(document.getElementById("map"));
this.map.addControl(new GSmallMapControl());
this.map.addControl(new GMapTypeControl());
this.map.setCenter(new GLatLng(26, -80.5), 8);
// Creates a marker at the given point with the given number label
function createMarker(point, tag) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(tag);
});
return marker;
}
// Get the xml file for this region
GDownloadUrl("SE_Data.xml", function(data, responseCode) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var tag = (("<p align='left'><font face='verdanda'><strong>") + markers[i].getAttribute("company") + ("</strong></font><br />") +
markers[i].getAttribute("ADDR1") + ("<br />") +
markers[i].getAttribute("CITY") + (", ") +
markers[i].getAttribute("ST") + (" ") +
markers[i].getAttribute("ZIP") + ("<br />PH: ") +
markers[i].getAttribute("PHONE") + ("<br />Website: <a href='http://") +
markers[i].getAttribute("WEBSITE") + ("' target='_blank'>") +
markers[i].getAttribute("WEBSITE") + ("</a></p>"));
map.addOverlay(createMarker(point, tag));
}
});
}
//]]>
</script>
</head>
<body>
<form action ="search.aspx" runat="server">
<table>
<tr>
<td>
<img src="images/flamap1.gif" width="350" height="306" border="0" usemap="#MAP2">
<map name="MAP2">
<area shape="poly" coords="118,18,118,18,135,65,108,76,23,44,20,14" href="javascript:NW()">
<area shape="poly" coords="123,30,214,37,222,82,210,82,203,102,188,99,134,62" href="javascript:NC()">
<area shape="poly" coords="248,29,245,44,260,89,240,90,227,85,222,76,216,40,220,35,229,27" href="javascript:NE()">
<area shape="poly" coords="196,161,188,151,198,130,196,103,209,102,217,111,213,119,223,125,222,162" href="javascript:CW()">
<area shape="poly" coords="264,182,255,184,252,188,241,188,240,173,223,173,224,125,214,118,220,109,209,100,205,101,207,84,221,84,235,89,247,102,250,111,257,111,265,123,266,160,261,161,256,167" href="javascript:C()">
<area shape="poly" coords="291,179,273,182,266,183,257,168,268,161,265,123,256,109,251,106,240,93,261,92,281,123" href="javascript:CE()">
<area shape="poly" coords="264,239,251,243,236,236,199,169,204,164,222,163,221,175,240,173,239,188,254,189,269,199" href="javascript:SW()">
<area shape="poly" coords="249,244,264,240,270,199,255,188,268,184,294,181,303,200,302,229,294,269,280,283,233,297" href="javascript:SE()">
</map><br>
</td>
<td align="center" valign="middle" bgcolor="#D7D7D7" >
<a name="NE">
<div class="buttonstyle" id="map" style='width: 340px; height: 400px'>
</div>
</a></td>
</tr>
</table>
</form>
</body>
I hope I have been clear enough in explaining my intent.