我正在寻找一种方法,使用Google Maps API v3根据路线的起点,航点和目的地计算美国各州的里程数.
我曾尝试使用谷歌距离矩阵API,但这是计算2点之间的距离,这是好的,但我需要分解每个州旅行的里程数.用于税收目的(IFTA运输报告).
我做了很多谷歌搜索并查看了文档,但我没有看到任何计算每个州的里程数.
我知道如何使用谷歌地图,我知道这是可能的,因为我在一个视频上看到它.没有我能展示的代码,因为我不知道该怎么做.有什么想法吗?
我找到的有用链接:
如何使用Google Map API V3绘制路线并在飞行中计算路线时间和距离http://www.c-sharpcorner.com/UploadFile/8911c4/how-to-draw-routes-and-calculate-route-time-和距离上/
如何使用Google Maps API构建远程查找器http://www.1stwebdesigner.com/distance-finder-google-maps-api/
我正在为一种非常复杂的发票方法计算税款。我无法解释整个过程,但如果您有任何问题,我会尽我所能回答。
我在 JS 中提出了一组对象:
[
{row_id: "20003859", expense_id: "429", tax_select: "tax1", tax_id: "1", tax_name: "GST 5%", tax_no: "", tax_value: "13.23"},
{row_id: "20003859", expense_id: "429", tax_select: "tax2", tax_id: "3", tax_name: "QST 9.975%", tax_no: "", tax_value: "26.38"},
{row_id: "20003840", expense_id: "409", tax_select: "tax1", tax_id: "1", tax_name: "GST 5%", tax_no: "", tax_value: "13.23"},
{row_id: "20003840", expense_id: "409", tax_select: "tax2", tax_id: "3", tax_name: "QST 9.975%", tax_no: "", tax_value: "26.38"},
{row_id: "20003870", expense_id: "419", tax_select: "tax1", tax_id: "2", tax_name: "HST 13%", tax_no: "", …
Run Code Online (Sandbox Code Playgroud) 我有这个:
$ids = "1,2,3,4,5";
$sqlQuery = "SELECT id, moderation_date
FROM table_live
WHERE id IN (".$ids.")";
$q = $this->CI->db->query($sqlQuery);
if($q->num_rows() > 0) {
foreach ($q->result() as $row) {
$arr[] = $row;
}
}
return $arr;
Run Code Online (Sandbox Code Playgroud)
如果 table_live 中存在所有 id 并返回,这一切正常
array([id] => 1 [moderation_date] => 2012-04-11 12:55:57)....
Run Code Online (Sandbox Code Playgroud)
问题:如果我发送一个 ids 1-2-3-4-5 列表,其中只有 1-2-5 匹配 IN LIST 子句,我需要返回列表中的所有内容,对于那些与列表不匹配的空值.
array([id] => 3 [moderation_date] => null)
Run Code Online (Sandbox Code Playgroud) 我在MySQL中存储的数字为总数(十进制16,2)1423.28
在进行一些计算后,我从PHP中显示它:
function calculate_balance($total){
//get total paid from another function
$total_paid = ...
if ($total_paid == 0){
return $total;
}else{
return $total-$total_paid
}
}
$balance = calculate_balance($total);
echo number_format($balance, 2); //returns 1.00
Run Code Online (Sandbox Code Playgroud)
我试过了
number_format((float)$balance, 2);
number_format(floatval($balance), 2);
Run Code Online (Sandbox Code Playgroud)
UPDATE
var_dump($balance)
我得到了以下输出.
string(8) "1,423.28" float(152) string(6) "252.00" string(6) "247.50" string(6) "247.50" string(6) "247.50" string(6) "549.90" string(6) "495.00" float(0) string(6) "284.76" float(265)
它的工作正常,没有number_format()
1000以下的价值.例如:如果余额等于252.00
echo $balance;
Run Code Online (Sandbox Code Playgroud)
产量
252.00