Ok, now I understand. Another issue just came up. It seems that my map keeps getting reset to default when the user clicks the button.
My body tag has a onLoad attribute, which calls the initialize() function from my Javascript. In there, the map is created and the center point is set with GMaps API. When the user clicks an ASP.NET button, is it going to post-back and then re-load that initialize function? If that is the case, then I will never get the results I need because it is being reset.
Thanks
EDIT: Here is the code I have so far, maybe someone could take a look at it and give me a suggestion. Here is the HTML.
<body onload="initialize()" onunload="GUnload()">
<form id="maps" runat="server">
<!-- Main Content -->
<div id="main">
<h1 id="title"> Directions to Crystal Ridge </h1>
<br />
<br />
<div id="map_canvas"></div>
<div id="inputcontrol">
<br />
<span class="normaltext">Enter your address for directions to Crystal Ridge</span>
<br />
<asp:TextBox ID="addressinput" runat="server"></asp:TextBox>
<asp:Button ID="gobutton" runat="server" Text="Go!" OnClientClick="goDirections()" />
</div>
<div id="directions"></div>
</div>
</form>
</body>
Here is the Javascript Code.
var map; // Map Object
var directionsPanel; // Panel for Directions Text
var directions; // Map overlay directions
// Initialize the map function
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas")); // create the map
map.setCenter(new GLatLng(42.920477, -88.009707), 13); // set the center
map.addControl(new GLargeMapControl()); // add the zoom and pan controls
// Create Marker for Ski Hill
var hill = new GMarker(new GLatLng(42.920477, -88.009707));
var markertext = '<span class="btitle">Crystal Ridge</span>' + '<br />' +
'<span>7900 W Crystal Ridge Dr</span>' + '<br />' + '<span class="baddress">Frankin, WI 53132</span>';
map.addOverlay(hill);
hill.openInfoWindowHtml(markertext); // Crystal Ridge Text Bubble
//Add Directions Module
directionsPanel = document.getElementById("directions"); // create the directions panel
directions = new GDirections(map, directionsPanel); // make a new directions object
}
}
function goDirections() {
var addresses; // full address string
var fromAddress; // the from address
fromAddress = document.getElementById("<%=addressinput.clientid%>").value; // use textbox text as from address
addresses = 'from: ' + fromAddress + ' to: 7900 W Crystal Ridge Dr, Franklin, WI'; // create the full string
directions.load(addresses); // load the directions
}