Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map MarkerManager: Cannot call method substr of undefined

I have a web application that is using the below Google Maps open source MarkerManager JavaScript to draw Geo Locations on a Google Map. It suddenly stopped working and is complaining about calling the substr method of something that is undefined. The Google main.js is having this issue all the sudden?

Line 98 of MarkerManager.js (local code):

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

Line 24 and 25 of https://maps.gstatic.com/intl/en_us/mapfiles/api-3/10/15a/main.js (Google Code):

function pf(a,b){a.f[b]||(a.f[b]=k,a.e.ne(function(c){O(c.b[b],function(b){a.d[b]||pf(a,b)});c=c.d;c.C[b]||(c.n?(c.e[D](b),c.d||(c.d=n[Hb](P(c,c.L),0))):le(c.b,de(c.f,b)+".js"))}))}of[H].Hc=function(a,b){var c=this,d=c.n;c.e.ne(function(e){var f=e.b[a]||[],g=e.e[a]||[],h=d[a]=be(f[G],function(){delete d[a];qf[f[0]](b);O(g,function(a){d[a]&&d[a]()})});O(f,function(a){c.d[a]&&h()})})};function rf(a,b){Vd(of).Hc(a,b)}var qf={},sf=ed.google.maps;sf.__gjsload__=rf;Hd(sf.modules,rf);delete sf.modules;function tf(a,b,c){var d=Vd(of);if(d.d[a])b(d.d[a]);else{var e=d.b;e[a]||(e[a]=[]);e[a][D](b);c||pf(d,a)}}function uf(a,b){var c=Vd(of);c.d[a]=b;O(c.b[a],function(a){a(b)});delete c.b[a]}function vf(a,b,c){var d=[],e=be(K(a),function(){b[Yb](l,d)});O(a,function(a,b){tf(a,function(a){d[b]=a;e()},c)})};function wf(){}wf[H].route=function(a,b){tf("directions",function(c){c.Ph(a,b,k)})};function S(a,b,c,d){na(this,a);Ia(this,b);this.j=c||"px";this.L=d||"px"}var xf=new S(0,0);Ba(S[H],function(){return"("+this[u]+", "+this[B]+")"});S[H].b=function(a){return!a?m:a[u]==this[u]&&a[B]==this[B]};S[H].equals=S[H].b;function T(a,b){this.x=a;this.y=b}var yf=new T(0,0);Ba(T[H],function(){return"("+this.x+", "+this.y+")"});T[H].b=function(a){return!a?m:a.x==this.x&&a.y==this.y};T[H].equals=T[H].b;T[H].round=function(){this.x=zd(this.x);this.y=zd(this.y)};T[H].md=bd(0);function zf(a){this.F=this.D=da;this.G=this.H=-da;O(a,P(this,this[jb]))}function Af(a,b,c,d){var e=new zf;e.F=a;e.D=b;e.G=c;e.H=d;return e}Ka(zf[H],function(){return!(this.F<this.G&&this.D<this.H)});oa(zf[H],function(a){a&&(this.F=yd(this.F,a.x),this.G=wd(this.G,a.x),this.D=yd(this.D,a.y),this.H=wd(this.H,a.y))});zf[H].getCenter=function(){return new T((this.F+this.G)/2,(this.D+this.H)/2)};var Bf=Af(-da,-da,da,da),Cf=Af(0,0,0,0);function Df(a){if(!Td(a)||!a)return""+a;a.__gm_id||(a.__gm_id=++Ef);return""+a.__gm_id}var Ef=0;function U(){}I=U[H];I.get=function(a){var b=Ff(this)[a];if(b){a=b.eb;var b=b.Bc,c="get"+Gf(a);return b[c]?b[c]():b.get(a)}return this[a]};I.set=function(a,b){var c=Ff(this),d=c[a];if(c[Ob](a)&&d){var c=d.eb,d=d.Bc,e="set"+Gf(c);if(d[e])d[e](b);else d.set(c,b)}else this[a]=b,Hf(this,a),c[a]=l};I.notify=function(a){var b=Ff(this),c=b[a];b[Ob](a)&&c?c.Bc[Eb](c.eb):Hf(this,a)};I.setValues=function(a){for(var b in a){var c=a[b],d="set"+Gf(b);if(this[d])this[d](c);else this.set(b,c)}};I.setOptions=U[H][tb];
Pa(I,Zc());function Hf(a,b){var c=b+"_changed";if(a[c])a[c]();else a[tc](b);var c=If(a,b),d;for(d in c){var e=c[d];Hf(e.Bc,e.eb)}R[r](a,b[Nc]()+"_changed")}var Jf={};function Gf(a){return Jf[a]||(Jf[a]=a[Cb](0,1).toUpperCase()+a[Cb](1))}function Ff(a){a.gm_accessors_||(a.gm_accessors_={});return a.gm_accessors_}function If(a,b){a[xc]||(a.gm_bindings_={});a[xc][Ob](b)||(a[xc][b]={});return a[xc][b]}

Error: Google Console

Script Snippet:

 MarkerManager.prototype.initialize = function (map, opt_opts) {
      var me = this;

      opt_opts = opt_opts || {};
      me.tileSize_ = MarkerManager.DEFAULT_TILE_SIZE_;

      var mapTypes = map.mapTypes;

      // Find max zoom level
      var mapMaxZoom = 1;
      for (var sType in mapTypes ) {
//below line is line 98
        if (typeof map.mapTypes.get(sType) === 'object' && typeof map.mapTypes.get(sType).maxZoom === 'number') {
          var mapTypeMaxZoom = map.mapTypes.get(sType).maxZoom;
          if (mapTypeMaxZoom > mapMaxZoom) {
            mapMaxZoom = mapTypeMaxZoom;
          }
        }
      }
like image 335
c12 Avatar asked Nov 21 '12 04:11

c12


2 Answers

I've also had a problem with two applications that use gmaps + markermanager

To temporarily solve the problem, I had to change from release to v3.9 api (Google Maps JavaScript API v3)

https://maps.googleapis.com/maps/api/js?v=3.9&sensor=false

===========================================

This problem is already reported to gmaps-api-issues, and the proposed solution works with v3.9, v3.10 and v3.11:

http://code.google.com/p/gmaps-api-issues/issues/detail?id=4543&q=markermanager&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Stars%20ApiType%20Internal

===========================================

Try editing the file markermanager.js

Change this line:

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

to

if (sType!="constructor" && typeof map.mapTypes.get(sType) === 'object' && typeof map.mapTypes.get(sType).maxZoom === 'number') {

like image 117
antondepalacios Avatar answered Sep 28 '22 21:09

antondepalacios


I had the same issue appearing in markermanagerv1.1

there the spoken line (98) looked slightly different:

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

still, changing it to the line mentioned above solved the problem:

if (sType!="constructor" && typeof map.mapTypes.get(sType) === 'object' && typeof map.mapTypes.get(sType).maxZoom === 'number') {
like image 31
Oliver Avatar answered Sep 26 '22 21:09

Oliver