Gmaps.js停止工作 [英] Gmaps.js stopped working

查看:68
本文介绍了Gmaps.js停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从一天到另一天,Gmaps.js库停止工作...我创建了一个带有3个标记的地图,并且它们具有InfoWindows,并且在InfoWindow中添加了一个小的路由选项,您可以在其中在其中输入您的地址,Gmap会将您路由到该Point.

from one day to another the Gmaps.js Library stopped working... I've created a map with 3 Markers on it and they had InfoWindows and I've added a little routing option in the InfoWindow where you could've typed your address in and Gmaps routed you to that Point.

现在在过去的2周中没有进行任何更改,我无法使其正常工作:地图加载没有任何问题,但是当我单击标记时,地图会自动消失.

Now without changing anything in the past 2 weeks, I can't get it to work anymore: The map loads without any problem but when I click on a marker the map kills itself.

在以下网址: http://gruber.tv/z/#standorte

当我在Firefox中加载地图时,我可以看到许多太多的递归"错误,它们都来自Google的main.js.

When I load the map in Firefox I can see many "too much recursion" errors and they all come from Google's main.js

我希望有人能帮助我!

最好的问候 iDave

Best Regards iDave

推荐答案

查看为每个标记处理click事件的代码:

Look at your code that handles the click event for each of your markers:

map.setCenter( e.position.k, e.position.D );

gmaps中的setCenter()方法采用纬度和经度参数. kD看起来像这些的明智名称吗? :-)

The setCenter() method in gmaps takes latitude and longitude arguments. Do k and D look like sensible names for these? :-)

我怀疑您是在开发代码时通过在开发人员工具中四处查看来找到这些属性的,对吗?在该行代码上设置一个断点,然后在到达代码行时再看一遍.

I suspect that you found these properties by looking around in the developer tools while developing your code, is that right? Set a breakpoint on that line of code and take another look when you get there.

就像,没有kD属性.现在,它具有AF属性.好吧,这不会.

Yikes, there are no k or D properties there any more. Now it has A and F properties instead. Well, this won't do.

但是您看到在其下方的__proto__属性吗?展开它,您将看到position对象的可用方法.注意那里的lat()lng()方法.这些更有意义,因此请尝试使用它们:

But do you see the __proto__ property right below that? Expand that and you'll see the available methods for the position object. Note the lat() and lng() methods there. These make a lot more sense, so try them:

map.setCenter( e.position.lat(), e.position.lng() );

此处发生的情况:e.position是Google Maps API中的LatLng对象. API对象具有许多未记录的内部属性,以及已记录的属性和方法. lat()lng()记载了获取纬度的方法和LatLng对象的经度.您发现的其他属性在API内部使用,但并不意味着在您自己的代码中使用. Google通过一个"minifier"运行所有JavaScript API代码,该minifier任意更改内部名称以缩短代码,但保持文档化的公共名称完整无缺.因此,每隔几周,当他们更新API时,任何未记录的内部名称都可能会更改.

What happened here: e.position is a LatLng object from the Google Maps API. The API objects have a number of undocumented internal properties, along with documented properties and methods. lat() and lng() are the documented methods to get the latitude and longitude from a LatLng object. The other properties you discovered are used internally in the API, but they aren't meant for use in your own code. Google runs all their JavaScript API code through a "minifier" that changes internal names arbitrarily to shorten the code but keeps the documented public names intact. So every few weeks when they update their API, any of the undocumented internal names may change.

这篇关于Gmaps.js停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆