【发布时间】:2012-10-22 07:12:31
【问题描述】:
我正在尝试使用 google 的 jsapi 获取客户端的当前位置,但我将 'google.loader' 视为未定义。知道为什么会发生这种情况吗?下面给出的是我使用的代码 sn-p。
$.getScript('http://www.google.com/jsapi', function()
{
if(google.loader.ClientLocation) {
var visitor_lat = google.loader.ClientLocation.latitude;
var visitor_lon = google.loader.ClientLocation.longitude;
var visitor_city = google.loader.ClientLocation.address.city;
var visitor_region = google.loader.ClientLocation.address.region;
var visitor_country = google.loader.ClientLocation.address.country;
var visitor_countrycode = google.loader.ClientLocation.address.country_code;
console.log("Your location is: " + visitor_country);
}});
【问题讨论】:
标签: javascript jquery google-maps google-maps-api-3 geolocation