var panorama;
var DistanceMatrix;
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
function InitializeMap() {
directionsDisplay = new google.maps.DirectionsRenderer();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions =
{
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('directionpanel'));
var control = document.getElementById('control');
control.style.display = 'block';
}
function calcRoute() {
debugger;
var start = document.getElementById('startvalue').value;
var end = document.getElementById('endvalue').value;
var request = {
origin: start,
destination: end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
//var hdnfldVariable = document.getElementById('hdnfldVariable');
//hdnfldVariable.value = request;
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}
function initialize() {
panorama = new google.maps.StreetViewPanorama(
document.getElementById('street-view'),
{
position: { lat: 37.869260, lng: -122.254811 },
pov: { heading: 165, pitch: 0 },
zoom: 1
});
}
function Dist()
{
DistanceMatrix = new google.maps.
}
function Button1_onclick() {
debugger;
calcRoute();
initialize();
}
window.onload = InitializeMap;
| |||||||
Start Value | |||||||
End Value | |||||||
Distance | |||||||
Total Fare | <%-- |
public partial class Pickup3 : System.Web.UI.Page
{
string dkm, ds, distance;
string origin, destination;
double conv = 0.62137;
double miles, d2;
string xmlResult = null;
XmlDocument doc = new XmlDocument();
static int Taxicount;
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//double dist = Convert.ToDouble(Session["taxi_distance"]);
double veh = Convert.ToDouble(Session["taxi_vehicle"]);
//startvalue2.Text = Session["taxi_origin"].ToString();
//endvalue2.Text = Session["taxi_destination"].ToString();
}
}
protected void Button2_Click1(object sender, EventArgs e)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://maps.googleapis.com/maps/api/distancematrix/xml?origins=" + startvalue.Text + "&destinations=" + endvalue.Text + "&mode=Car&language=us-en&sensor=false");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader resStream = new StreamReader(response.GetResponseStream());
xmlResult = resStream.ReadToEnd();
doc.LoadXml(xmlResult);
try
{
if (doc.DocumentElement.SelectSingleNode("/DistanceMatrixResponse/row/element/status").InnerText.ToString().ToUpper() != "OK")
{
//Response.Write("");
return;
}
XmlNodeList xnList = doc.SelectNodes("/DistanceMatrixResponse");
foreach (XmlNode xn in xnList)
{
if (xn["status"].InnerText.ToString() == "OK")
{
dkm = doc.DocumentElement.SelectSingleNode("/DistanceMatrixResponse/row/element/distance/text").InnerText;
ds = dkm.Replace("km", " ");
distance = ds.Trim();
d2 = Convert.ToDouble(distance);
// miles = conv * d2;
origin = xn["origin_address"].InnerText.ToString();
destination = xn["destination_address"].InnerText.ToString();
Session.Add("taxi_origin", origin);
Session.Add("taxi_destination", destination);
// Session.Add("taxi_distance", miles);
Session.Add("shams", "Return Date and Time");
//Session.Add("taxi_cartype", Rdb_CarType.SelectedValue);
//double dist = Convert.ToDouble(Session["taxi_distance"]);
double veh = Convert.ToDouble(Session["taxi_vehicle"]);
//Lbl_Distance.Text = Math.Round(dist, 2).ToString() + " miles";
// Lbl_Fare.Text = Math.Round(dist * 2.5 * veh, 2).ToString();
string a = "1";
Session.Add("BookTaxi", a);
Taxicount++;
Session.Add("TaxiCount", Taxicount.ToString());
if (Session["taxi_oneway"] == "One Way")
{
//Lbl_Distance.Text = Math.Round(dist, 2).ToString() + " miles";
// Lbl_Fare.Text = Math.Round(dist * 2.5 * veh, 2).ToString();
}
Session.Add("totalfare", Lbl_Fare.Text);
//Session.Add("totaldistance", Lbl_Distance.Text);
}
}
}
catch
{
Response.Write("");
return;
}
}
}
These are my codes how to calculate fare of between origin and destination as per kilometer plz help guys


Answers
Know the answer? Post it. Somebody with the same question will find it here.