Google Maps API的库JS文件分析(3)
在Google Maps API提供的JS文件中,引用了一个后台的JS库文件,该文件针对不同的浏览器有三个版本,这几天因为我想给我的Google Map扩展一些功能,所以研究了这个文件,我现在正打算陆续将我注释过的该文件放在网上,该文件一共有7000多行,我会分段渐渐的注释出来,我是按照分类注释的,所以并不会按照该JS文件顺序。
该文件Google作了处理,所有的变量名都被处理成了简单的a,b,c,d之类,所以理解起来比较费劲。
该JS文件是以IE版本的http://maps.google.com/mapfiles/maps.21.js来分析的,其他的几个我觉得基本的架构也应该差不多,所以我没有仔细看,实际上,这个文件Google也会不停的更新(在我写这个文章的时候,我发现Google已经更新到maps.25.js了),不过我想架构上也不会有太大的变动吧。
由于该文件是在比较复杂,所以难免会出现理解错误的情况,请谅解!
下面是第三个(这是地图图片创建与处理的代码):
1
//img图片控件的类
2
function ma()
3
{
4
}
5
//创建img图片控件的方法,参数分别为:
6
//a 图片的路径
7
//b 图片的宽度
8
//c 图片的高度
9
//d 图片的左位置style.left
10
//e 图片的上位置style.left
11
//f 图片的z-index属性
12
//i i为true时,固定图片大小,i为false时,将拉伸图片
13
//g 图片的附加样式,比如noscreen
14
//h document或其他用来创建img标签的对象
15
//m 自定义的创建img标签的函数,用a,i,h作参数
16
ma.create=function(a,b,c,d,e,f,i,g,h,m)
17
{
18
var o;
19
h=h||document;
20
if(!m)
21
{
22
o=h.createElement("img");
23
if(a)
24
{
25
o.src=a
26
}
27
}
28
else
29
{
30
o=m(a,i,h)
31
}
32
if(b&&c)
33
{
34
o.style.width=k(b);
35
o.style.height=k(c);
36
o.width=b;
37
o.height=c;
38
}
39
if(e||(d||(e==0||d==0)))
40
{
41
o.style.position="absolute";
42
o.style.left=k(d);
43
o.style.top=k(e)
44
}
45
if(f||f==0)
46
{
47
o.style.zIndex=f
48
}
49
if(t.type==1)
50
{
51
o.unselectable="on";
52
o.onselectstart=Za //返回false
53
}
54
else
55
{
56
o.style.MozUserSelect="none"
57
}
58
if(t.type==1)
59
{
60
o.galleryImg="no" //不显示"My Pictures"图片工具栏
61
}
62
o.style.border="0";
63
o.style.padding="0";
64
o.style.margin="0";
65
o.oncontextmenu=Za; //返回false
66
if(g)
67
{
68
Aa(o,g)
69
}
70
return o
71
};
72
//img扩展图片控件的类
73
function n()
74
{
75
}
76
//创建img图片控件的方法,参数说明参照ma,使用了自定义的createElement方法
77
n.create=function(a,b,c,d,e,f,i,g,h)
78
{
79
return ma.create(a,b,c,d,e,f,i,g,h,n.createElement)
80
};
81
//自定义的createElement方法,参数如下
82
//a 图片的路径
83
//b i为true时,固定图片大小,i为false时,将拉伸图片
84
//c document或其他用来创建img标签的对象
85
n.createElement=function(a,b,c)
86
{
87
//定义hasFilters属性
88
if(typeof arguments.callee.hasFilters=="undefined")
89
{
90
var d=document.createElement("div");
91
arguments.callee.hasFilters=typeof d.style.filter!="undefined"
92
}
93
var e;
94
if(arguments.callee.hasFilters)
95
{
96
//PNG_cache是没有图片的时候在该位置显示的一个替代层
97
var f=c.PNG_cache;
98
if(f&&f.childNodes.length>0)
99
{
100
e=f.removeChild(f.lastChild)
101
}
102
else
103
{
104
e=c.createElement("div");
105
e.style.fontSize=k(1);
106
n.destroyBeforeUnload(e) //在窗口退出时执行清理图片占用内存的任务
107
}
108
if(!e.loader)
109
{
110
e.loader=c.createElement("img");
111
e.loader.style.visibility="hidden";
112
e.loader.onload=function() //在图片加载完成之后显示图片
113
{
114
if(!e.cleared)
115
{
116
e.style.filter=n.alphaImageLoader(this.src,this.ieCrop); //后台加载图片
117
e.src=a
118
}
119
}
120
}
121
}
122
else
123
{
124
e=c.createElement("img")
125
}
126
n.setImage(e,a,b); 设置图片加载路径
127
return e
128
};
129
//生成后台加载图片的filter字符串
130
n.alphaImageLoader=function(a,b)
131
{
132
var c="DXImageTransform.Microsoft.AlphaImageLoader";
133
var d=",sizingMethod="+(b?"crop":"scale");
134
return"progid:"+c+'(src="'+a+'"'+d+")"
135
};
136
//删除图片,a是待删除的图片,b是document对象
137
n.remove=function(a,b)
138
{
139
if(a.nodeName=="DIV")
140
{
141
if(!b.PNG_cache)
142
{
143
b.PNG_cache=b.createElement("div");
144
b.PNG_cache.style.display="none";
145
b.body.appendChild(b.PNG_cache)
146
}
147
b.PNG_cache.appendChild(a);
148
n.clearImage(a)
149
}
150
else
151
{
152
a.parentNode.removeChild(a)
153
}
154
};
155
//设置图片a的属性,b是图片路径,c可参考createElement的c参数
156
n.setImage=function(a,b,c)
157
{
158
if(a.tagName=="DIV")
159
{
160
a.cleared=false;
161
a.loader.ieCrop=c||false;
162
a.loader.src=b
163
}
164
else
165
{
166
a.src=b
167
}
168
};
169
//清空图片a,假如设置了b(空图片的路径),则将a路径设置为b
170
n.clearImage=function(a,b)
171
{
172
if(a.tagName=="DIV")
173
{
174
a.cleared=true;
175
a.style.filter=""
176
}
177
else
178
{
179
a.src=b
180
}
181
};
182
//设置在窗口退出时执行清理图片占用内存的任务
183
n.destroyBeforeUnload=function(a)
184
{
185
if(!n.cleanupQueue)
186
{
187
n.cleanupQueue=[];
188
j.addBuiltInListener(window,"unload",n.onUnload)
189
}
190
n.cleanupQueue.push(a)
191
};
192
//执行清理图片占用内存的任务
193
n.onUnload=function()
194
{
195
for(var a=0;a<n.cleanupQueue.length;++a)
196
{
197
n.destroyImage(n.cleanupQueue[a])
198
}
199
};
200
//清理图片占用内存
201
n.destroyImage=function(a)
202
{
203
if(a.loader)
204
{
205
a.loader.onload=null;
206
a.loader=null
207
}
208
};
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/None.gif)
3
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
4
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
5
![](/Images/OutliningIndicators/None.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/None.gif)
9
![](/Images/OutliningIndicators/None.gif)
10
![](/Images/OutliningIndicators/None.gif)
11
![](/Images/OutliningIndicators/None.gif)
12
![](/Images/OutliningIndicators/None.gif)
13
![](/Images/OutliningIndicators/None.gif)
14
![](/Images/OutliningIndicators/None.gif)
15
![](/Images/OutliningIndicators/None.gif)
16
![](/Images/OutliningIndicators/None.gif)
17
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
18
![](/Images/OutliningIndicators/InBlock.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/InBlock.gif)
21
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
22
![](/Images/OutliningIndicators/InBlock.gif)
23
![](/Images/OutliningIndicators/InBlock.gif)
24
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
25
![](/Images/OutliningIndicators/InBlock.gif)
26
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
27
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
28
![](/Images/OutliningIndicators/InBlock.gif)
29
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
30
![](/Images/OutliningIndicators/InBlock.gif)
31
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
32
![](/Images/OutliningIndicators/InBlock.gif)
33
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
34
![](/Images/OutliningIndicators/InBlock.gif)
35
![](/Images/OutliningIndicators/InBlock.gif)
36
![](/Images/OutliningIndicators/InBlock.gif)
37
![](/Images/OutliningIndicators/InBlock.gif)
38
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
39
![](/Images/OutliningIndicators/InBlock.gif)
40
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
41
![](/Images/OutliningIndicators/InBlock.gif)
42
![](/Images/OutliningIndicators/InBlock.gif)
43
![](/Images/OutliningIndicators/InBlock.gif)
44
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
45
![](/Images/OutliningIndicators/InBlock.gif)
46
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
47
![](/Images/OutliningIndicators/InBlock.gif)
48
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
49
![](/Images/OutliningIndicators/InBlock.gif)
50
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
51
![](/Images/OutliningIndicators/InBlock.gif)
52
![](/Images/OutliningIndicators/InBlock.gif)
53
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
54
![](/Images/OutliningIndicators/InBlock.gif)
55
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
56
![](/Images/OutliningIndicators/InBlock.gif)
57
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
58
![](/Images/OutliningIndicators/InBlock.gif)
59
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
60
![](/Images/OutliningIndicators/InBlock.gif)
61
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
62
![](/Images/OutliningIndicators/InBlock.gif)
63
![](/Images/OutliningIndicators/InBlock.gif)
64
![](/Images/OutliningIndicators/InBlock.gif)
65
![](/Images/OutliningIndicators/InBlock.gif)
66
![](/Images/OutliningIndicators/InBlock.gif)
67
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
68
![](/Images/OutliningIndicators/InBlock.gif)
69
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
70
![](/Images/OutliningIndicators/InBlock.gif)
71
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
72
![](/Images/OutliningIndicators/None.gif)
73
![](/Images/OutliningIndicators/None.gif)
74
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
75
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
76
![](/Images/OutliningIndicators/None.gif)
77
![](/Images/OutliningIndicators/None.gif)
78
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
79
![](/Images/OutliningIndicators/InBlock.gif)
80
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
81
![](/Images/OutliningIndicators/None.gif)
82
![](/Images/OutliningIndicators/None.gif)
83
![](/Images/OutliningIndicators/None.gif)
84
![](/Images/OutliningIndicators/None.gif)
85
![](/Images/OutliningIndicators/None.gif)
86
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
87
![](/Images/OutliningIndicators/InBlock.gif)
88
![](/Images/OutliningIndicators/InBlock.gif)
89
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
90
![](/Images/OutliningIndicators/InBlock.gif)
91
![](/Images/OutliningIndicators/InBlock.gif)
92
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
93
![](/Images/OutliningIndicators/InBlock.gif)
94
![](/Images/OutliningIndicators/InBlock.gif)
95
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
96
![](/Images/OutliningIndicators/InBlock.gif)
97
![](/Images/OutliningIndicators/InBlock.gif)
98
![](/Images/OutliningIndicators/InBlock.gif)
99
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
100
![](/Images/OutliningIndicators/InBlock.gif)
101
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
102
![](/Images/OutliningIndicators/InBlock.gif)
103
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
104
![](/Images/OutliningIndicators/InBlock.gif)
105
![](/Images/OutliningIndicators/InBlock.gif)
106
![](/Images/OutliningIndicators/InBlock.gif)
107
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
108
![](/Images/OutliningIndicators/InBlock.gif)
109
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
110
![](/Images/OutliningIndicators/InBlock.gif)
111
![](/Images/OutliningIndicators/InBlock.gif)
112
![](/Images/OutliningIndicators/InBlock.gif)
113
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
114
![](/Images/OutliningIndicators/InBlock.gif)
115
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
116
![](/Images/OutliningIndicators/InBlock.gif)
117
![](/Images/OutliningIndicators/InBlock.gif)
118
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
119
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
120
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
121
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
122
![](/Images/OutliningIndicators/InBlock.gif)
123
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
124
![](/Images/OutliningIndicators/InBlock.gif)
125
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
126
![](/Images/OutliningIndicators/InBlock.gif)
127
![](/Images/OutliningIndicators/InBlock.gif)
128
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
129
![](/Images/OutliningIndicators/None.gif)
130
![](/Images/OutliningIndicators/None.gif)
131
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
132
![](/Images/OutliningIndicators/InBlock.gif)
133
![](/Images/OutliningIndicators/InBlock.gif)
134
![](/Images/OutliningIndicators/InBlock.gif)
135
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
136
![](/Images/OutliningIndicators/None.gif)
137
![](/Images/OutliningIndicators/None.gif)
138
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
139
![](/Images/OutliningIndicators/InBlock.gif)
140
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
141
![](/Images/OutliningIndicators/InBlock.gif)
142
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
143
![](/Images/OutliningIndicators/InBlock.gif)
144
![](/Images/OutliningIndicators/InBlock.gif)
145
![](/Images/OutliningIndicators/InBlock.gif)
146
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
147
![](/Images/OutliningIndicators/InBlock.gif)
148
![](/Images/OutliningIndicators/InBlock.gif)
149
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
150
![](/Images/OutliningIndicators/InBlock.gif)
151
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
152
![](/Images/OutliningIndicators/InBlock.gif)
153
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
154
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
155
![](/Images/OutliningIndicators/None.gif)
156
![](/Images/OutliningIndicators/None.gif)
157
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
158
![](/Images/OutliningIndicators/InBlock.gif)
159
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
160
![](/Images/OutliningIndicators/InBlock.gif)
161
![](/Images/OutliningIndicators/InBlock.gif)
162
![](/Images/OutliningIndicators/InBlock.gif)
163
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
164
![](/Images/OutliningIndicators/InBlock.gif)
165
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
166
![](/Images/OutliningIndicators/InBlock.gif)
167
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
168
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
169
![](/Images/OutliningIndicators/None.gif)
170
![](/Images/OutliningIndicators/None.gif)
171
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
172
![](/Images/OutliningIndicators/InBlock.gif)
173
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
174
![](/Images/OutliningIndicators/InBlock.gif)
175
![](/Images/OutliningIndicators/InBlock.gif)
176
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
177
![](/Images/OutliningIndicators/InBlock.gif)
178
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
179
![](/Images/OutliningIndicators/InBlock.gif)
180
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
181
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
182
![](/Images/OutliningIndicators/None.gif)
183
![](/Images/OutliningIndicators/None.gif)
184
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
185
![](/Images/OutliningIndicators/InBlock.gif)
186
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
187
![](/Images/OutliningIndicators/InBlock.gif)
188
![](/Images/OutliningIndicators/InBlock.gif)
189
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
190
![](/Images/OutliningIndicators/InBlock.gif)
191
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
192
![](/Images/OutliningIndicators/None.gif)
193
![](/Images/OutliningIndicators/None.gif)
194
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
195
![](/Images/OutliningIndicators/InBlock.gif)
196
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
197
![](/Images/OutliningIndicators/InBlock.gif)
198
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
199
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
200
![](/Images/OutliningIndicators/None.gif)
201
![](/Images/OutliningIndicators/None.gif)
202
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
203
![](/Images/OutliningIndicators/InBlock.gif)
204
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
205
![](/Images/OutliningIndicators/InBlock.gif)
206
![](/Images/OutliningIndicators/InBlock.gif)
207
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
208
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
posted on 2005-10-19 10:54 K_Reverter 阅读(605) 评论(0) 编辑 收藏 举报