title: Google Map MarkerManager: Cannot call method substr of undefined
body: <p>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?</p>
  
  <p><strong>Line 98 of MarkerManager.js (local code):</strong></p>
  
  <pre><code> if (typeof map.mapTypes.get(sType) === 'object' &amp;&amp; typeof map.mapTypes.get(sType).maxZoom === 'number') {
  </code></pre>
  
  <p><strong>Line 24 and 25 of <a href="https://maps.gstatic.com/intl/en_us/mapfiles/api-3/10/15a/main.js" rel="noreferrer">https://maps.gstatic.com/intl/en_us/mapfiles/api-3/10/15a/main.js</a> (Google Code):</strong></p>
  
  <pre><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]&amp;&amp;d[a]()})});O(f,function(a){c.d[a]&amp;&amp;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]&amp;&amp;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&amp;&amp;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&lt;this.G&amp;&amp;this.D&lt;this.H)});oa(zf[H],function(a){a&amp;&amp;(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)&amp;&amp;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)&amp;&amp;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]}
  </code></pre>
  
  <p><strong>Error:</strong>
  <img src="https://i.stack.imgur.com/ndvFB.png" alt="Google Console"></p>
  
  <p><strong>Script Snippet:</strong></p>
  
  <pre><code> 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' &amp;&amp; typeof map.mapTypes.get(sType).maxZoom === 'number') {
            var mapTypeMaxZoom = map.mapTypes.get(sType).maxZoom;
            if (mapTypeMaxZoom &gt; mapMaxZoom) {
              mapMaxZoom = mapTypeMaxZoom;
            }
          }
        }
  </code></pre>