Google Maps API - 提供“概述”折线的方向毫无意义

时间:2017-09-20 18:47:15

标签: google-maps google-maps-api-3

我正在使用路线api,使用xGoogle Maps API航点之间获得最佳路线。我的电话是这样的:

https://maps.googleapis.com/maps/api/directions/json?key=MY_KEY&origin=Exeter%2C+UK&destination=London&region=uk&waypoints=optimize:true|52.80443%2C1.3974969999999303|51.33700547604255%2C-2.5970759440972415|50.430475%2C-4.305309999999963

返回看似合适的结果(所有驾驶说明)。但是,它还会返回我要在我的网站上显示的概述折线。但无论何时我解码它(无论是在我的网站上还是使用他们的Polyline Utility),它都会显示一些奇怪的线条,这些线条似乎与路线不相符(它有正确的起点,但没有显示路线和某些点它在一条直线上移动很远)。例如:

Incorrect Polyline

这是我获得上述请求路线的折线。正如你所看到的那样,它有很多在水中航行的线路......

在我的网站上,我会像那样显示聚合物(但在他们的折线工具中,我得到相同的一行):

var decodedPath = google.maps.geometry.encoding.decodePath("<?=$response->routes[0]->overview_polyline->points?>");
var poly = new google.maps.Polyline({
                  path: decodedPath,
                  strokeColor: '#FF0000',
                  strokeOpacity: 1.0,
                  strokeWeight: 3,
                  map: map
           });

我做错了什么?如何获得正确的折线以显示实际路线的轮廓?

谢谢!

1 个答案:

答案 0 :(得分:3)

我从your request服务获得的回复是:

   var getBudgetTask = new List<Task>();

        foreach (Checkbook c in list)
        {
            var getAcc = Task.Run(() =>
            {

                List<IAccount> accLst = new List<IAccount>();
                accLst = data.getAccounts(c.CheckbookID).ToList();
                ///for each account get the budget
                foreach (IAccount acc in accLst)
                {
                    IBudget actual = data.getBudget(c.CompanyNumber, "Actual", DateTime.Now.Year, acc.GLAccount);
                    IBudget budget = data.getBudget(c.CompanyNumber, "Budget", DateTime.Now.Year, acc.GLAccount);
                    for (int i = 1; i <= 12; i++)
                    {
                        string name = "Month" + i;
                        final[i - 1].Actual += decimal.Parse(budgetvariable.GetProperty(name).GetValue(actual).ToString());
                        final[i - 1].Budget += decimal.Parse(budgetvariable.GetProperty(name).GetValue(budget).ToString());
                    }
                }
            });

            getBudgetTask.Add(getAcc);
        }

        await Task.WhenAll(getBudgetTask);

在那里有两个转义的反斜杠(&#34; \&#34;),它们需要&#34;未转义&#34;:

proof of concept fiddle

enter image description here