我在我的javascript中用斜线标出的圆角地图,因为我有 mu路,需要根据距离另行计算。
一切都发挥了巨大作用,但距离只能返回其中一条。
我感到,这是我用在阿加西呼吁绘制地图的方式做的。 从以下法典中可以提出什么意见?
for (var i = 1; i <= numJourneys; i++) {
var mapContainer = directionsMap + i;
var directionContainer = $( #getDistance + i);
$.ajax({
async: false,
type: "POST",
url: "Journey/LoadWayPoints",
data: "{ args : " + i + " }",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d != [] ) {
var map = new GMap2(document.getElementById(mapContainer));
var distance = directionContainer;
var wp = new Array();
//routes
var counter = 0;
$.each(content, function () {
wp[counter] = new GLatLng(this[ Lat ], this[ Long ]);
counter = counter + 1;
});
map.clearOverlays();
map.setCenter(wp[0], 14);
// load directions
directions = new GDirections(map);
GEvent.addListener(directions, "load", function () {
alert(directions.getDistance());
//directionContainer.html(directions.getDistance().html);
});
directions.loadFromWaypoints(wp, { getSteps: true });
}
}
});
}