首页 \ 问答 \ 如何将Google地图持续时间和距离计算器四舍五入(How to round Google Maps Duration
and Distance calculator)
我有一个小的距离和持续时间计算器,我想知道我将如何舍入/减少我的最终数字,例如,而不是最终持续时间为7.433333333333334分钟或最终距离为3.604公里。 我得到7分钟和4公里。
这是我目前的代码:
Distance Calculator
I have a small distance and duration calculator and I'm wondering how I would go about rounding up/down my final figures so for example, instead of a final duration of 7.433333333333334
mins or a final distance of 3.604 KMs. I'd get 7 minutes and 4 Kms.
Here is my current code:
Distance Calculator
更新时间:2022-03-15 09:03
相关问答
更多
在创建线时计算线的长度。 一旦它变得大于或等于“走”的距离,停止向其添加点。 var lengthMeters = 0; var legs = response.routes[0].legs; for (i = 0; i < legs.length; i++) { var steps = legs[i].steps; for (j = 0; j <
steps.length; j++) { var nextSegment = steps[j].path; fo ...
如果您查询伦敦,地理编码器将始终返回相同的坐标 ,因此您可以将其标记为向下 ,然后将查询中的新坐标 与 保存的坐标 进行比较 。 如果匹配则会增加成本。 The geocoder will always return the same coordinates if you query London, so you could just mark that down and
then compare the new coordinates from the query with the saved ones. ...
我能够通过在XMLParser类中添加另一个方法来解决这个问题: public String getSecondValue(Element item, String str) { NodeList n = item.getElementsByTagName(str); return this.getElementValue(n.item(1)); } 这是活动中的用法:
import java.util.ArrayList; import java.util.H ...
显然,在法国有超过1个城市名为Batilly。 要获得类似于Google地图的结果,您可以: 通过Places-TextSearch获取位置。 对我来说它返回所需的位置(49.1710200,5.9693580) 在DistanceMatrix-请求中使用此位置 There obviously are more than 1 city named Batilly in
france. To get a result similar to Google Maps you may: get the locati ...
您正在覆盖每条路线的路段,总距离和时间。 如果您想要合并所有单个路线的组合的总数来克服Google Maps Javascript API v3(免费版)上的航路点限制,您需要合并“路线”以及每条路线的路段。 function drawRouteMap(locations) { var start, end; var waypts = []; for (var k =
0; k < locations.length; k++) { if (k >= 1 && k <= ...
更改
至
后 map = new google.map ...
我相信你要找的是Math.round()函数。 I believe what you are looking for is the Math.round() function.
public void parseJson(JSONObject jObject) { List>> routes = new ArrayList<>(); JSONArray jRoutes; JSONArray jLegs; JSONArray jSteps; JSONObject jDistance = null; JSONObject
jDura ...
我可能错了,但从查看你的代码:
你在dom中用距离/持续时间来计算div。 假设信息出现在div中确定...要进入信息窗口,您需要使用: infowindow ...
尝试这个:- if (total<40) { var cost = parseInt(total) * 1.95; } else { var cost = parseInt(total) * 1.65; } Try this:- if (total<40) { var cost = pa ...
}