0
我想通过Google地图API动态获取客户位置。通过Google地图API获取客户位置
下面是我的代码:
/*Call external api dynamically*/
var script = document.createElement("script");
script.src = "http://www.google.com/jsapi?key=" + api_key + "&callback=loadm";
script.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(script);
/*function */
function loadm() {
google.load("maps", "3", {other_params:"sensor=false", "callback" : defmap});
}
function defmap() {
if(google.loader.ClientLocation){
alert(google.loader.ClientLocation.latitude+" "+google.loader.ClientLocation.longitude};
}
我已经尝试过了,但在返回空值。代码中有错误吗?
喜坎德人,对不起,我已经离开了右括号即时通讯在我的问题的编码部分。但它存在于应用程序中。应用程序运行时没有语法错误。但无法获得客户位置。它返回空值。 – davidlee 2010-06-28 15:15:27
好吧,我把它放在一个.html文件中的确切代码,放在标签中,给了我我的(大约)位置......使用Firefox和Firefox在Linux上进行了测试 – kender 2010-06-29 12:08:39