作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试从此函数中获取结果。但是,我的页面上没有返回任何内容,只是“此示例调用执行计算并返回结果的函数:”。我需要这个函数从属性表中获取数据库中的每个邮政编码并找到距离。另外,一个邮政编码设置为始终相同,因此我需要设置它,而另一个邮政编码将是属性表中的邮政编码。
<?php
include ("../connect.php");
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p>This example calls a function which performs a calculation, and returns the result:</p>
<p id="demo"></p>
<script type="text/javascript">
var x = getDistance(52.482799000000000, -2.000643000000000, 52.48463500000000, -1.980759000000000);
function getDistance($latitude1, $longitude1, $latitude2, $longitude2) {
$earth_radius = 6371;
$postLat = deg2rad($latitude2 - $latitude1);
$postLon = deg2rad($longitude2 - $longitude1);
$a = sin($postLat/2) * sin($postLat/2) + cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * sin($postLon/2) * sin($postLon/2);
$c = 2 * asin(sqrt($a));
$d = $earth_radius * $c;
//$distance_miles = $km * 0.621371; //distance in miles
return $d;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
最佳答案
你在哪里使用 x 变量?
我期望这样的事情:
<p>This example calls a function which performs a calculation, and returns the result:
<div id="result">
</div>
</p>
var x = getDistance(52.482799000000000, -2.000643000000000, 52.48463500000000, -1.980759000000000);
$('#result').text(x);
关于javascript - GetDistance Javascript 在有一些参数值时不返回任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36234233/
我正在使用 getdist绘制一些模拟结果。在 jupyter 中只写这一行 g = plots.getSubplotPlotter() g.triangle_plot([samples, sampl
我正在尝试从此函数中获取结果。但是,我的页面上没有返回任何内容,只是“此示例调用执行计算并返回结果的函数:”。我需要这个函数从属性表中获取数据库中的每个邮政编码并找到距离。另外,一个邮政编码设置为始终
//单独文件中的位置类 package tld; import java.util.*; public class Location { private double x; private doubl
我正在实现一个 paper.js 脚本,该脚本是使用 paperscript 类型脚本元素内联编写的。现在它已经被 require.js 加载并且工作正常,我将它安装到 window 对象,使其可以全
我是一名优秀的程序员,十分优秀!