Ga naar inhoud
Log in om dit te volgen  
boebie

[ HELP ] - Miles naar kilometers converten

Aanbevolen berichten

Codeblok:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//var taxi_type;
var stops_count = 0;
var baby_count = 0;
var taxi_type_m;
var taxi_type_s;
var markerBounds = new google.maps.LatLngBounds();
var geocoder = new google.maps.Geocoder();
var markers = new Array();
var directionsDisplay;
var directionsService;
var map;
var lats = ;
var lngs = ;
count_markers = 0;
var waypoints = new Array();
jQuery(document).ready(function()
{
// code for google auto suggestion address for pick up location
var input = document.getElementById(source);
var autocomplete = new google.maps.places.Autocomplete(input);
// code for Google auto suggestion address for destination location
var drop = document.getElementById(destination);
var drop_autocomplete = new google.maps.places.Autocomplete(drop);
});
function doCalculation()
{
var cartypes=document.getElementById(cartypes).value;
var address = document.getElementById(source).value;
var destination = document.getElementById(destination).value;
if(cartypes.trim()==)
{
alert("Please Select Car Type. if Cartype is empty, then you need to inser first from admin side.");
return false;
}
else if(address.trim() == ) {
alert("Please Enter Pickup Address");
source = ;
return false;
}
else if(destination.trim() == ) {
alert("Please Enter Drop Off Address");
destination = ;
return false;
}
else
{
calc();
}
}
function calc() {
var source = document.getElementById("source").value;
var stops_counts = document.getElementById("stops_count").value;
var destination = document.getElementById("destination").value;
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [source],
destinations: [destination],
travelMode: google.maps.TravelMode.DRIVING,
avoidHighways: false,
avoidTolls: false
}, callback);
function callback(response, status) {
console.log(status);
if (status == google.maps.DistanceMatrixStatus.OK) {
var origins = response.originAddresses;
var destinations = response.destinationAddresses;
for (var i = 0; i < origins.length; i++) {
var results = response.rows[i].elements;
for (var j = 0; j < results.length; j++) {
var element = results[j];
if (element.status == "NOT_FOUND") {
document.getElementById("source").value = ;
alert("Please enter valid pickup address.");
return 0;
}
if (element.status == "ZERO_RESULTS") {
document.getElementById("destination").value = ;
document.getElementById("source").value = ;
alert("Please enter valid addresses.");
return 0;
}
var distance = element.distance.text;
var duration = element.duration.text;
console.log("dist:: " + distance + " dura:: " + duration);
document.getElementById("duration").value = duration;
document.getElementById("distance").value = distance;
var m_distance = 0.00, mile_distance = 0.00, ft_distance = 0.00, km_distance = 0.00, estimated_fare;
var distance_array = distance.split(" ");
distance_array[0] = distance_array[0].replace(/,/g, ); // 1125, but a string, so convert it to number
distance_array[0] = parseFloat(distance_array[0]);
if (distance_array[1] == m) {
m_distance = distance_array[0] / 1000;
mile_distance = parseFloat(m_distance) / 1.6;
} else if (distance_array[1] == ft) {
ft_distance = distance_array[0];
mile_distance = parseFloat(ft_distance) / 5280;
} else if (distance_array[1] == km) {
km_distance = parseFloat(distance_array[0]);
mile_distance = parseFloat(km_distance) / 1.6;
} else if (distance_array[1] == mi) {
mile_distance = distance_array[0];
}
dur_mins = 0;
var dur_array = duration.split(" ");
if (dur_array.length == 2) {
if (dur_array[1] == "mins") {
dur_mins = dur_array[0];
} else if (dur_array[1] == "hours" || dur_array[1] == "hour") {
dur_mins = parseFloat(dur_array[0]) * 60;
}
} else if (dur_array.length == 4) {
dur_mins = parseFloat(dur_array[2]);
dur_mins = dur_mins + parseFloat(dur_array[0]) * 60;
}
console.log("miles: " + mile_distance);
console.log("mins: " + dur_mins);
var stops_count = document.getElementById("stops_count").value;
var minutefare =document.getElementById(minutefare).value;
var stopfare=document.getElementById(stopfare).value;
var milefare=document.getElementById(milefare).value;
var seatfare=document.getElementById(seatfare).value;
var cartype=document.getElementById(cartypes).value;
var curr=document.getElementById(currfare).value;
var cartype=parseInt(cartype);
if (document.getElementById("baby_seat")) {
baby_count = parseFloat(document.getElementById("baby_count").value);
}
/*
if (taxi_type_s == true) {
estimated_fare = cartype + (mile_distance  milefare) + (dur_mins minutefare) + (baby_count  seatfare) + (stops_count stopfare);
estimated_fare = $ + estimated_fare.toFixed(2);
} else {
*/
estimated_fare = cartype + (mile_distance  milefare) + (dur_mins minutefare) + (baby_count  seatfare) + (stops_count stopfare);
estimated_fare = curr + estimated_fare.toFixed(2);
//}
if (mile_distance < .2) {
mile_distance = mile_distance * 5280;
mile_distance = mile_distance.toFixed(2) + Feet;
} else {
// estimated_fare
mile_distance = mile_distance.toFixed(2) + Miles;
}
document.getElementById("distance").value = mile_distance;
document.getElementById("fare").value = estimated_fare;
document.getElementById("duration").value = duration;
dsp();
document.getElementById("po").innerHTML = "<span class=nearest> Estimated Fare : " + jQuery("#fare").val() + "</span><br>";
jQuery("#po").append("<span class=nearest>Distance :" + jQuery("#distance").val() + "</span><br>");
jQuery("#po").append("<span class=nearest>Duration :" + jQuery("#duration").val() + "</span><br>");
}
}
}
}
}
function dsp() {
if (jQuery("#po").is(":hidden")) {
}
else {
jQuery("#po").hide();
}
jQuery("#po").slideDown("slow", function() {
});
}
function set_baby() {
var baby = document.getElementById("baby_seat");
//if(baby.checked){
// document.getElementById("baby_count").value=1;
//}
//else{
// document.getElementById("baby_count").value=;
//}
}
var s = "";
var count = 0;
var id = 0;
function clear_form_elements(ele) {
count=0;
first_time = true;
jQuery("#po").html("");
jQuery("#po").css("display","none");
tags = ele.getElementsByTagName(input);
for (i = 0; i < tags.length; i++) {
switch (tags[i].type) {
case password:
case text:
tags[i].value = ;
break;
case checkbox:
case radio:
tags[i].checked = false;
break;
}
}
document.getElementById("baby_count").value = 0;
document.getElementById("stops_div").value = "";
document.getElementById("stops_count").value = 0;
}
jQuery(document).on(click,.rem,function(){
var id = jQuery(this).attr(content);
//............
var h1=window.location.pathname;
var base_url= window.location.origin+h1;
base_url=base_url.replace(/wp-admin/admin.php,);
jQuery.post(base_url+/wp-admin/admin-ajax.php, {action: asi_deletecar, id:id},function(data){
//alert(data);
});
});

Deel dit bericht


Link naar bericht
Delen op andere sites
Codeblok:
1
2
3
4
5
6
function m2k (miles) {
    var mi = parseFloat(miles);
    var km = "";
    if (!isNaN(mi)) km = mi * 1.609344;
  alert(km);
}

Deel dit bericht


Link naar bericht
Delen op andere sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reageer op dit topic...

×   Geplakt als RTF formaat tekst.   Plak in plaats daarvan als platte tekst

  Er zijn maximaal 75 emoji toegestaan.

×   Je link werd automatisch ingevoegd.   Tonen als normale link

×   Je vorige inhoud werd hersteld.   Leeg de tekstverwerker

×   Je kunt afbeeldingen niet direct plakken. Upload of voeg afbeeldingen vanaf een URL in

Log in om dit te volgen  

×
×
  • Nieuwe aanmaken...