简体   繁体   English

Gmaps.js 停止工作

[英]Gmaps.js stopped working

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.从一天到另一天,Gmaps.js 库停止工作......我创建了一张地图,上面有 3 个标记,他们有 InfoWindows,我在 InfoWindow 中添加了一个小路由选项,您可以在其中输入您的地址在和 Gmaps 路由你到那个点。

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.现在,在过去 2 周内没有进行任何更改,我无法再让它工作了:地图加载没有任何问题,但是当我单击标记时,地图会自行终止。

Heres the URL: http://gruber.tv/z/#standorte网址如下: http : //gruber.tv/z/#standorte

When I load the map in Firefox I can see many "too much recursion" errors and they all come from Google's main.js当我在 Firefox 中加载地图时,我可以看到许多“递归过多”错误,它们都来自 Google 的 main.js

I hope someone can help me!我希望有一个人可以帮助我!

Best Regards iDave最好的问候 iDave

Look at your code that handles the click event for each of your markers:查看处理每个标记的click事件的代码:

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

The setCenter() method in gmaps takes latitude and longitude arguments. gmaps 中的setCenter()方法接受纬度和经度参数。 Do k and D look like sensible names for these? kD看起来像这些名字吗? :-) :-)

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.在该行代码上设置一个断点,并在到达那里时再看一看。

Yikes, there are no k or D properties there any more.哎呀,那里不再有kD属性了。 Now it has A and F properties instead.现在它具有AF属性。 Well, this won't do.嗯,这不行。

But do you see the __proto__ property right below that?但是你看到__proto__属性就在它下面吗? Expand that and you'll see the available methods for the position object.展开它,您将看到position对象的可用方法。 Note the lat() and lng() methods there.注意那里的lat()lng()方法。 These make a lot more sense, so try them:这些更有意义,所以试试它们:

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

What happened here: e.position is a LatLng object from the Google Maps API.这里发生了什么: e.position是来自 Google Maps API 的LatLng对象。 The API objects have a number of undocumented internal properties, along with documented properties and methods. API 对象具有许多未记录的内部属性,以及记录的属性和方法。 lat() and lng() are the documented methods to get the latitude and longitude from a LatLng object. lat()lng()是从LatLng对象获取纬度和经度文档化方法 The other properties you discovered are used internally in the API, but they aren't meant for use in your own code.您发现的其他属性在 API 内部使用,但并不打算在您自己的代码中使用。 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.谷歌通过一个“压缩器”运行他们所有的 JavaScript API 代码,它可以任意更改内部名称以缩短代码,但保持记录的公共名称完整无缺。 So every few weeks when they update their API, any of the undocumented internal names may change.因此,每隔几周,当他们更新 API 时,任何未记录的内部名称都可能会更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM