我想獲得客戶的當前位置使用谷歌的jsapi,但我越來越'谷歌。加載'爲未定義。任何想法爲什麼會發生?下面給出的是我使用的代碼片段。undefined地理位置
$.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);
}});
如果您查看源代碼'ClientLocation'中已經填充了實際的數據。 – TheZ
那麼爲什麼'google.loader'未定義? – Halcyon
未知,該腳本創建'window ['google'] ['loader']',請親自看看:http://www.google.com/jsapi – TheZ