【发布时间】:2018-08-23 22:24:33
【问题描述】:
我已编写以下代码来访问我的位置,但此代码未显示我当前的位置。
我需要做出哪些改变。因为我是初学者,知道的不多。
提前致谢。
<body>
<a href="#" id="get_location">Get location</a>
<div id="map">
<iframe id="google_map" width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.co.in?output=embed"></iframe>
</div>
<script>
var c= function(pos)
{
var lat= pos.coords.latitude, long= pos.coords.longitude, coords= lat + ',' + long;
document.getElementById('google_map').setAttribute('src','https://maps.google.co.in/?q=' + coords + '&z=60&output=embed');
}
document.getElementById('get_loaction').onclick = function()
{
navigator.geolocation.getCurrentPosition(c);
return false;
}
</script>
</body>
【问题讨论】:
-
谁在调用函数
c
标签: javascript html google-maps geolocation