我有一个网络应用程序,它使用以下Google Maps开源MarkerManager JavaScript在Google地图上绘制地理位置。它突然停止工作,并抱怨调用substr方法的东西是未定义的。 Google main.js突然出现了这个问题?
MarkerManager.js的第98行(本地代码):
if (typeof map.mapTypes.get(sType) === 'object' && typeof map.mapTypes.get(sType).maxZoom === 'number') {
https://maps.gstatic.com/intl/en_us/mapfiles/api-3/10/15a/main.js(Google Code)第24和25行:
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]}
错误:
脚本代码段
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;
}
}
}
答案 0 :(得分:11)
我还遇到了两个使用gmaps + markermanager
的应用程序的问题要暂时解决问题,我必须从发布版更改为v3.9 api(Google Maps JavaScript API v3)
https://maps.googleapis.com/maps/api/js?v=3.9&sensor=false
===========================================
此问题已报告给gmaps-api-issues,建议的解决方案适用于v3.9,v3.10和v3.11:
===========================================
尝试编辑文件markermanager.js
更改此行:
if(typeof map.mapTypes.get(sType)==='object'&amp;&amp; typeof map.mapTypes.get(sType).maxZoom ==='number'){
到
if(sType!=“constructor”&amp;&amp; typeof map.mapTypes.get(sType)==='object'&amp;&amp; typeof map.mapTypes.get(sType).maxZoom ==='number '){
答案 1 :(得分:2)
我在markermanagerv1.1
中出现了同样的问题 话语线(98)看起来略有不同: if (mapTypes.hasOwnProperty(sType) && mapTypes.get(sType).maxZoom === 'number') {
仍然,将其更改为上述行解决了问题:
if (sType!="constructor" && typeof map.mapTypes.get(sType) === 'object' && typeof map.mapTypes.get(sType).maxZoom === 'number') {