我有一个 HTML5 表单,它使用地理定位器脚本从平板电脑 GPS 中填充纬度/经度和海拔高度的文本框。数据是使用 WGS84 数据返回的,但用于存储表单数据的数据库需要 NAD83 数据。
是否有脚本可以在填充字段之前将默认 WGS84 数据转换为 NAD83,还是必须对所有数据进行后处理?
<fieldset>
<div> Latitude: <input type="text" id="lat" name="lat" ></div>
<div>Longitude: <input type="text" id="long" name="long" value=""></div>
<div><label><input type="text" id="acc" name="long" value="" data-mini="true"></label>
<button onclick="getLocationConstant()" value="Get Location" data-mini="true"></button>
</div>
<script>
function getLocationConstant()
{
if(navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(onGeoSuccess,onGeoError);
} else {
alert("Your browser or device doesn't support Geolocation");
}
}
// If we have a successful location update
function onGeoSuccess(event)
{
document.getElementById("lat").value = event.coords.latitude;
document.getElementById("long").value = event.coords.longitude;
document.getElementById("height").value = event.coords.altitude;
document.getElementById("acc").value = event.coords.accuracy +"% accuracy";
}
// If something has gone wrong with the geolocation request
function onGeoError(event)
{
alert("Error code " + event.code + ". " + event.message);
}
</script>
<div>Elevation: <input type="text" name="height" id="height"></div>
</fieldset>