Hi All,
I'm trying to create an array of distances using parameters from a
database. The problem I have is with the loop. I only seem to retrieve
the last value. Can anyone help me? Here is the code:
<html>
<head>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("db.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "SELECT LOCATION, LOCATION_CTY, GOAL, GOAL_CTY FROM ASSETS",
conn
p=rs.GetRows()
%>
<script src="http://maps.google.com/maps?
file=api&v=2&sensor=false&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-
m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></
script>
<%for i=0 to 3%>
<script language="javascript">
function go() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
gdir = new GDirections(map, document.getElementById
("directions"));
GEvent.addListener(gdir, "load", onGDirectionsLoad);
setDirections("<%=p(0,i)%>"+", "+"<%=p(1,i)%>","<%=p(2,i)
%>"+", "+"<%=p(3,i)%>", "en_US");
}
}
function setDirections(atAddress, toAddress, locale) {
gdir.load("from: " + atAddress + " to: " + toAddress,
{ "locale": locale });
}
function onGDirectionsLoad()
{
alert(Math.round(gdir.getDistance().meters/1000) + " km");
}
</script>
<%next%>
<%
rs.close
conn.close
%>
</head>
<body onUnload="GUnload()">
<a href="javascript:go();">Link</a>
<div id="map_canvas" style="width: 310px; height: 400px;
display:none"></div>
<div id="directions" style="width: 275px; display:none"></div>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.