【发布时间】:2013-09-08 13:41:32
【问题描述】:
我正在尝试用地理位置查询的结果填充两个字段。这是我写的第一个 javascripts。
这是我当前的代码:http://jsfiddle.net/spadez/aGupn/2/
$(function (getLocation) {
var Geo = {};
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
}
//Get the latitude and the longitude;
function success(position) {
Geo.lat = position.coords.latitude;
Geo.lng = position.coords.longitude;
populateHeader(Geo.lat, Geo.lng);
}
function error() {
console.log("Geocoder failed");
}
function populateHeader(lat, lng) {
$('#lat').html(lat);
$('#lng').html(lng);
}
});
我哪里出错了?
【问题讨论】:
标签: javascript jquery geolocation