简体   繁体   中英

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.

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.

Heres the URL: 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

I hope someone can help me!

Best Regards iDave

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

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

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.

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

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() );

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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