gpt4 book ai didi

javascript - 谷歌地图标记管理器 : Cannot call method substr of undefined

转载 作者:搜寻专家 更新时间:2023-11-01 04:52:33 25 4
gpt4 key购买 nike

我有一个 Web 应用程序,它使用下面的 Google map 开源 MarkerManager JavaScript 在 Google map 上绘制地理位置。它突然停止工作并提示调用未定义的 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 的第 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]}

错误: Google Console

脚本片段:

 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;
}
}
}

最佳答案

我也遇到了两个使用 gmaps + markermanager 的应用程序的问题

为了暂时解决问题,我只好从 release 改成 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:

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

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

尝试编辑文件 markermanager.js

改变这一行:

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

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

关于javascript - 谷歌地图标记管理器 : Cannot call method substr of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13486271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com