Google地图无法在移动浏览器中使用

时间:2013-04-24 08:44:47

标签: javascript google-maps google-maps-api-3

我已按照here的说明操作,并在桌面设备上取得了很好的效果,但在移动浏览器中,地图只是空白(在Android,iOS上查看)。似乎脚本没有在移动设备上运行(浏览器中允许使用javascript),因为生成的页面在div#map_leads中没有执行代码。

This就是这样。

有人可以帮忙解决吗?

制作一个更清晰的page,其中只包含地图,一切正常......将尝试在网站上找到错误的代码。

我发现地图不起作用的原因是以下javascript:

(function() {

function t(e) {
this.path=e;
var t=this.path.split("."),n=t.slice(0,t.length-1).join("."),r=t[t.length-1];
this.at_2x_path=n+"@2x."+r
}

function n(e) {
this.el=e,this.path=new t(this.el.getAttribute("src"));
var n=this;
this.path.check_2x_variant(function(e){e&&n.swap()})
}

var e=typeof exports=="undefined"?window:exports;

e.RetinaImagePath=t,
t.confirmed_paths=[],
t.prototype.is_external=function(){
return!!this.path.match(/^https?\:/i)&&!this.path.match("//"+document.domain)
},
t.prototype.check_2x_variant=function(e){
var n,
r=this;

if(this.is_external())return e(!1);

if(this.at_2x_path in t.confirmed_paths)return e(!0);

n=new XMLHttpRequest,
n.open("HEAD",this.at_2x_path),
n.onreadystatechange=function(){
return n.readyState!=4?e(!1):n.status>=200&&n.status<=399?(t.confirmed_paths.push(r.at_2x_path),
e(!0)):e(!1)},
n.send()
},

e.RetinaImage=n,
n.prototype.swap=function(e){
function n(){
t.el.complete?(
t.el.setAttribute("width",t.el.offsetWidth),
t.el.setAttribute("height",t.el.offsetHeight),
t.el.setAttribute("src",e)
):setTimeout(n,5)}
typeof e=="undefined"&&(e=this.path.at_2x_path);
var t=this;
n()},

e.devicePixelRatio>1&&(window.onload=function(){
var e=document.getElementsByTagName("img"),t=[],r,i;
for(r=0;r<e.length;r++)i=e[r],t.push(new n(i))})})();

我自己把它分成了几行,因为它是在行中写的。将尝试修复它 - 认为img元素有问题。

1 个答案:

答案 0 :(得分:0)

在发布的脚本末尾添加了地图功能,工作正常。抱歉浪费你的时间!