'Google Maps Directions API is changing destination addresses
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);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
