问题描述
我正在使用地理位置api来获取我所在位置的纬度和经度..这是我的代码..
I am using geolocation api to get latitude and longitude of place i am in.. here is my code..
<script type='text/javascript'>
var x = document.getElementById('add');
var c = function (pos) {
var latitude = pos.coords.latitude;
var longitude = pos.coords.longitude;
coords = latitude + ',' + longitude;
document.getElementById('google_map').setAttribute('src', 'https://maps.google.com.np/?q=' + coords + '&z=20&output=embed');
x.innerHTML = "lat:" + latitude + "<br /> long: " + longitude;
}
<pre lang="cs">document.getElementById('get_location').onclick = function () {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(c);
return false;
} else {
alert("Geo Location is not supported on your current browser!");
}
}
</script>
这里pos.coords.latitude& pos.coords.longitude返回我的纬度和经度但问题有时它会返回完整的值,即。我的学位,分钟和秒钟显示我在我所在的确切位置,有时它只返回我的学位和分钟值,在几分钟内显示我是不同的地方,我不是..我怎么能得到全部价值,避免圆通过编码关闭值?
无论如何都要提前感谢..
here pos.coords.latitude & pos.coords.longitude returns my latitude and longitude but the problem is sometimes it returns full value ie. my degree, minutes and seconds showing me in the exact place where i am and sometimes it returns only my degree and round off value in minutes resulting to show me is different place where i am not.. how can i get full value and avoid round off value via coding??
anyway thanks in advance..
推荐答案
这篇关于如何使用地理位置获得我的经度和经度的确切价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!