Google地图方向API正在更改目标地址
我正在尝试使用Google Maps Directions API来计算路线的正确里程,并且它不断更改我的目的地地址从: 2369通过Mariposa E,Laguna Woods,CA 92637 to: B2369,2369通过Mariposa E,Laguna Woods,CA 92637
。 5.2mi。
感谢您的帮助!
var origin = new GoogleApi.Entities.Common.Address("27020 Alicia Pkwy, Laguna Niguel, CA 92677, USA");
var destination = new GoogleApi.Entities.Common.Address("2369 Via Mariposa E, Laguna Woods, CA 92637, USA");
// For some reason, Destination changes to B2369, 2369 Via Mariposa E, Laguna Woods, CA 92637, USA
// Expected Results: https://www.google.com/maps/dir/27020+Alicia+Pkwy,+Laguna+Niguel,+CA+92677/2369+Via+Mariposa+E,+Laguna+Woods,+CA+92637/@33.5899389,-117.746248,14z/data=!3m1!4b1!4m14!4m13!1m5!1m1!1s0x80dcef47fef5b78d:0xe6f974e512e89fdb!2m2!1d-117.7141775!2d33.5702304!1m5!1m1!1s0x80dce76420f8e66f:0x82dbfd8a0bfbe07f!2m2!1d-117.7497698!2d33.6096498!3e0
// Returned Results: https://www.google.com/maps/dir/27020+Alicia+Pkwy,+Laguna+Niguel,+CA+92677/B2369,+2369+Via+Mariposa+E,+Laguna+Woods,+CA+92637/@33.5951275,-117.7294664,14z/data=!3m1!4b1!4m14!4m13!1m5!1m1!1s0x80dcef47fef5b78d:0xe6f974e512e89fdb!2m2!1d-117.7141775!2d33.5702304!1m5!1m1!1s0x80dce88a6a634ebf:0x8e9c99fbe8beeef9!2m2!1d-117.7181169!2d33.6198264!3e0
var request = new DirectionsRequest()
{
Key = API,
Origin = new LocationEx(origin),
Destination = new LocationEx(destination),
Avoid = GoogleApi.Entities.Maps.Common.Enums.AvoidWay.Tolls,
TravelMode = GoogleApi.Entities.Maps.Common.Enums.TravelMode.Driving
};
var result = GoogleApi.GoogleMaps.Directions.Query(request);
var meters = result.Routes.First().Legs.Sum(s => s.Distance.Value);
routeData.Miles = getMiles(meters);
I'm trying to calculate the correct mileage of a route using Google Maps Directions API and it keeps changing my destination address FROM: 2369 Via Mariposa E, Laguna Woods, CA 92637 TO: B2369, 2369 Via Mariposa E, Laguna Woods, CA 92637.
Both are legitimate addresses if I go to the map (links provided in code below) but I can't seem to get Google to stop changing it resulting in 4.3mi instead of 5.2mi.
Thank you for your help!
var origin = new GoogleApi.Entities.Common.Address("27020 Alicia Pkwy, Laguna Niguel, CA 92677, USA");
var destination = new GoogleApi.Entities.Common.Address("2369 Via Mariposa E, Laguna Woods, CA 92637, USA");
// For some reason, Destination changes to B2369, 2369 Via Mariposa E, Laguna Woods, CA 92637, USA
// Expected Results: https://www.google.com/maps/dir/27020+Alicia+Pkwy,+Laguna+Niguel,+CA+92677/2369+Via+Mariposa+E,+Laguna+Woods,+CA+92637/@33.5899389,-117.746248,14z/data=!3m1!4b1!4m14!4m13!1m5!1m1!1s0x80dcef47fef5b78d:0xe6f974e512e89fdb!2m2!1d-117.7141775!2d33.5702304!1m5!1m1!1s0x80dce76420f8e66f:0x82dbfd8a0bfbe07f!2m2!1d-117.7497698!2d33.6096498!3e0
// Returned Results: https://www.google.com/maps/dir/27020+Alicia+Pkwy,+Laguna+Niguel,+CA+92677/B2369,+2369+Via+Mariposa+E,+Laguna+Woods,+CA+92637/@33.5951275,-117.7294664,14z/data=!3m1!4b1!4m14!4m13!1m5!1m1!1s0x80dcef47fef5b78d:0xe6f974e512e89fdb!2m2!1d-117.7141775!2d33.5702304!1m5!1m1!1s0x80dce88a6a634ebf:0x8e9c99fbe8beeef9!2m2!1d-117.7181169!2d33.6198264!3e0
var request = new DirectionsRequest()
{
Key = API,
Origin = new LocationEx(origin),
Destination = new LocationEx(destination),
Avoid = GoogleApi.Entities.Maps.Common.Enums.AvoidWay.Tolls,
TravelMode = GoogleApi.Entities.Maps.Common.Enums.TravelMode.Driving
};
var result = GoogleApi.GoogleMaps.Directions.Query(request);
var meters = result.Routes.First().Legs.Sum(s => s.Distance.Value);
routeData.Miles = getMiles(meters);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论