English 中文(简体)
不要返回距离
原标题:google maps call within a For Loop not returning distance

我在我的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 });
                        }
                    }
                });
            }
最佳回答

这个问题已降至未申报变量。 早在GEvent打电话之前,就有一个不同的方向,但实际上从未宣布过,因此没有清除。

var directions = new GDirections(map);

以上是我的工作。

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签