public async Task <JsonResult> processGoogleMap(HireBusVm data) { var origins = data.DeparturePoint; var destinations = data.DestinationPoint; DistanceDouble distance = new DistanceDouble(); var departLat = 0.00; var departLng = 0.00; var departCord = ""; var arriveLat = 0.00; var arriveLng = 0.00; var arriveCord = ""; string resultxml = string.Empty; string urlDepart = "https://maps.googleapis.com/maps/api/geocode/json?address=" + origins + "&key=" + ConfigurationManager.AppSettings["GoogleAPIKey"] + ""; string urlArrive = "https://maps.googleapis.com/maps/api/geocode/json?address=" + destinations + "&key=" + ConfigurationManager.AppSettings["GoogleAPIKey"] + ""; try { mapRootObject MapResponseJsonDepart = await Logical.GetDepartCord(urlDepart); List <mapResult> googleResponseElementDepart = MapResponseJsonDepart.results; if (googleResponseElementDepart.Count > 0) { foreach (mapResult rowDepart in googleResponseElementDepart) { departLat = rowDepart.geometry.location.lat; departLng = rowDepart.geometry.location.lng; departCord = departLat + "," + departLng; } } mapRootObject MapResponseJsonArrive = await Logical.GetArriveCord(urlArrive); List <mapResult> googleResponseElementArrive = MapResponseJsonArrive.results; if (googleResponseElementArrive.Count > 0) { foreach (mapResult rowArrive in googleResponseElementArrive) { arriveLat = rowArrive.geometry.location.lat; arriveLng = rowArrive.geometry.location.lng; arriveCord = arriveLat + "," + arriveLng; } } } catch (Exception ex) { Logical.WriteToLog(ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace); } try { string url = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=" + departCord + "&destinations=" + arriveCord + "&mode=driving&key=" + ConfigurationManager.AppSettings["GoogleAPIKey"] + ""; GoogleRootObject GoogleMapResponseJson = await Logical.GetDistance(url); List <Row> googleResponseElement = GoogleMapResponseJson.rows; if (googleResponseElement.Count > 0) { foreach (Row row in googleResponseElement) { List <Element> elements = row.elements; foreach (Element element in elements) { distance.distanceInKiloMeter = Convert.ToDouble(element.distance.value / 1000.00); } } } } catch (Exception ex) { Logical.WriteToLog(ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace); } Session["distance"] = distance; await StartHire(data); var hiredResponse = (getVehicleForHireResponse)Session["HireResponse"]; String page = Session["pageTogo"] as String; Tuple <DistanceDouble, String, getVehicleForHireResponse> response = new Tuple <DistanceDouble, String, getVehicleForHireResponse>(distance, page, hiredResponse); return(new JsonResult { Data = response, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }