2013-05-02 111 views
0

我有一个HTML5表单,它使用geolocator脚本从平板电脑GPS填充纬度/经度为&的文本框。数据使用WGS84数据返回,但用于存储表单数据的数据库需要NAD83数据。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> 

回答

0

在不同基准面或投影之间转换的公式太复杂。

有一个开源项目Proj4(javascript版本)可以做你想做的关于地图投影的每件事情。你可以从它得到:

http://trac.osgeo.org/proj/