Geolim4 / google-maps-utility-library-v3

Automatically exported from code.google.com/p/google-maps-utility-library-v3
Apache License 2.0
0 stars 0 forks source link

The new version or MarkerManager fails with Uncaught TypeError: Cannot read property 'maxZoom' of undefined #215

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Demo link or sample code:
http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markermanager/exa
mples/weather_map.html

What steps will reproduce the problem?
Developers console shows the error

Expected result:
No errors and Marker Manger layer showing up.

Actual result:
The layer does not show up, and error is thrown on the console.

Version: 
stable version of Google Maps Api JS v3

Original issue reported on code.google.com by kaska...@google.com on 4 Dec 2012 at 9:31

GoogleCodeExporter commented 9 years ago

Original comment by kaska...@google.com on 4 Dec 2012 at 9:32

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Object.getOwnPropertyNames(map.mapTypes) returns:
["terrain", "satellite", "gm_accessors_", "hybrid", "__e3_", "roadmap", 
"gm_bindings_"]

I guess we don't want to iterate on gm_accessors_ __e3_ and gm_bindings_ as it 
causes the error.

quick & dirty bugfix for production:

add the typeof === 'object' from markermanager v1.0

markermanager.js: L98

-- if (mapTypes.hasOwnProperty(sType) && mapTypes.get(sType).maxZoom === 
'number') {

++ if (mapTypes.hasOwnProperty(sType) && typeof mapTypes.get(sType) === 
'object' && mapTypes.get(sType).maxZoom === 'number') {

Original comment by nicolas....@gmail.com on 4 Dec 2012 at 11:13

GoogleCodeExporter commented 9 years ago
Another solution would be to iterate on google.maps.MapTypeId:

L97:
-- for (var sType in mapTypes ) {
++ for (var sType in google.maps.MapTypeId ) {

L98:
-- if (mapTypes.hasOwnProperty(sType) && mapTypes.get(sType).maxZoom === 
'number') {
++ if (mapTypes.get(sType.toLowerCase()).maxZoom === 'number') {

Original comment by nicolas....@gmail.com on 4 Dec 2012 at 5:12

GoogleCodeExporter commented 9 years ago
Seems that the last solution would be the more secure.

Original comment by doga...@gmail.com on 26 Dec 2012 at 5:09