0
我想存儲從訪問數據庫中的路線的距離,我幾乎在那裏,但只有最後的距離被提交到數據庫。你可以幫我嗎? 只有一個地址作爲來源,我試着用四個地址作爲目的地。無論如何,比爾。谷歌地圖V3 - 保存到數據庫
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script>
</head>
<body>
<script type="text/javascript">
var directionsService = new google.maps.DirectionsService();
var origem;
var destino;
var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = Z:\\Projetos\\GoogleMaps\\GoogleMaps.mdb;"
//Database Connection
var cn = new ActiveXObject("ADODB.Connection");
cn.Open(strConn);
//Recordset
var rsOrigem = new ActiveXObject("ADODB.Recordset");
var sqlOrigem = "select * from tblOrigem";
rsOrigem.Open(sqlOrigem, cn);
var rsDestino = new ActiveXObject("ADODB.Recordset");
var sqlDestino = "select * from tblDestino";
rsDestino.Open(sqlDestino, cn);
rsOrigem.Movefirst();
rsDestino.Movefirst();
while(!rsDestino.eof) {
origem = rsOrigem.fields("Endereco").value;
destino = rsDestino.fields("Endereco").value;
var myOptions = {
zoom:7,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var request = {
origin: origem,
destination: destino,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var rsGravar = new ActiveXObject("ADODB.Recordset");
rsGravar.Open("Select * From tblDestino Where Endereco = '" + destino + "'", cn, 1, 3);
rsGravar.Edit;
rsGravar.fields("Distancia").value = response.routes[0].legs[0].distance.value;
rsGravar.Update;
}
});
rsDestino.MoveNext();
}
rsOrigem.Close();
rsDestino.Close();
rsGravar.Close();
cn.Close();
</script>
</body>
</html>