/* * // https://developers.google.com/maps/documentation/javascript/directions * OK indicates the response contains a valid DirectionsResult. * NOT_FOUND indicates at least one of the locations specified in the request's origin, destination, or waypoints could not be geocoded. * ZERO_RESULTS indicates no route could be found between the origin and destination. * MAX_WAYPOINTS_EXCEEDED indicates that too many DirectionsWaypoint fields were provided in the DirectionsRequest. See the section below on limits for way points. * MAX_ROUTE_LENGTH_EXCEEDED indicates the requested route is too long and cannot be processed. This error occurs when more complex directions are returned. Try reducing the number of waypoints, turns, or instructions. * INVALID_REQUEST indicates that the provided DirectionsRequest was invalid. The most common causes of this error code are requests that are missing either an origin or destination, or a transit request that includes waypoints. * OVER_QUERY_LIMIT indicates the webpage has sent too many requests within the allowed time period. * OVER_DAILY_LIMIT: The webpage has gone over the daily limit of its request quota. * REQUEST_DENIED indicates the webpage is not allowed to use the directions service. * UNKNOWN_ERROR indicates a directions request could not be processed due to a server error. The request may succeed if you try again. * * ERROR: There was a problem contacting the Google servers. */ public static GoogleDirectionsReturnValue FromJson(string json) { GoogleDirectionsReturnValue retValue = Newtonsoft.Json.JsonConvert.DeserializeObject <GoogleDirectionsReturnValue>(json, Converter.Settings); if (!"OK".Equals(retValue.status, System.StringComparison.OrdinalIgnoreCase)) { throw new GoogleDirectionsException(retValue); } return(retValue); }
public static GoogleDirectionsReturnValue GetDirections(DirectionsUrlBuilder urlBuilder) { GoogleDirectionsReturnValue retVal = null; string url = urlBuilder.ToString(); using (System.Net.WebClient wc = new System.Net.WebClient()) { string result = wc.DownloadString(url); retVal = GoogleDirectionsReturnValue.FromJson(result); } return(retVal); }
public GoogleDirectionsException(GoogleDirectionsReturnValue api_result) : this(api_result.status + ": " + api_result.error_message) { }