对Google Maps API的JS文件解析(map.js)
我下载了Google Maps API所调用的JS文件的源文件,研究了一下,做了一点注释,现在放在下面
1var _mSiteName = 'Google Maps';
2var _mZoomIn = 'Zoom In';
3var _mZoomOut = 'Zoom Out';
4var _mZoomSet = 'Click to set zoom level';
5var _mZoomDrag = 'Drag to zoom';
6var _mPanWest = 'Go left';
7var _mPanEast = 'Go right';
8var _mPanNorth = 'Go up';
9var _mPanSouth = 'Go down';
10var _mLastResult = 'Return to the last result';
11var _mGoogleCopy = '?2005 Google';
12var _mDataCopy = 'Map data ?2005 ';
13var _mNavteq = 'NAVTEQ?';
14var _mTeleAtlas = 'Tele Atlas';
15var _mZenrin = 'ZENRIN';
16var _mZenrinCopy = 'Map ?2005 ';
17var _mNormalMap = 'Map';
18var _mNormalMapShort = 'Map';
19var _mHybridMap = 'Hybrid';
20var _mHybridMapShort = 'Hyb';
21var _mNew = 'New!';
22var _mTerms = 'Terms of Use';
23var _mKeyholeMap = 'Satellite';
24var _mKeyholeMapShort = 'Sat';
25var _mKeyholeCopy = 'Imagery ?2005 ';
26var _mScale = 'Scale at the center of the map';
27var _mKilometers = 'km';
28var _mMiles = 'mi';
29var _mMeters = 'm';
30var _mFeet = 'ft';
31var _mDecimalPoint = '.';
32var _mThousandsSeparator = ',';
33var _mMapErrorTile = 'We are sorry, but we don\'t have maps at this zoom level for this region.Try zooming out for a broader look.';
34var _mKeyholeErrorTile = 'We are sorry, but we don\'t have imagery at this zoom level for this region.Try zooming out for a broader look.';
35var _mTermsURL = 'http://www.google.com/help/terms_local.html';
36var _apiHash = '5f87579ff86792cf982d095a4228e3de6cdaf562';
37var _apiKey = 'ABQIAAAA7nPTPXCvzWYxyKdmbFQfTxRfh1ef-GeSz5gtCVpCKOPebNr1YhR23M_jRfeqAugNMsW3pZQJAwfCFw';
38var _mApiBadKey = 'The Google Maps API key used on this web site was registered for a different web site. You can generate a new key for this web site at http://www.google.com/apis/maps/.';
39function createMapSpecs()
40{
41 var mt = '';
42 var tv = 'w2.5';
43 var apitv = 'w2.5';
44 var hmt = '';
45 var htv = 'w2t.1';
46 var apihtv = 'w2t.1';
47 var kmt = '';
48 var kdomain = 'google.com';
49 var ktv = '3';
50 var kdisable = false;
51 var khauth = 'fzwq2uohc9nRek9eHfZgC_oFXnYU9GSk3iYwgw';
52 var kjapandatumhack = true;
53 var hybrid = (htv != '');
54 if (!arguments.callee.mapSpecs)
55 {
56 var mapSpecs = [];
57 var tileVersion = window._apiKey ? apitv : tv;
58 var hTileVersion = window._apiKey ? apihtv : htv;
59 var mapCopy = (tileVersion != tv) ? G_MAP_API_COPYRIGHTS :G_MAP_DEFAULT_COPYRIGHTS;
60 var hybridCopy = (hTileVersion != htv) ? G_MAP_API_COPYRIGHTS :G_MAP_DEFAULT_COPYRIGHTS;
61 _GOOGLE_MAP_TYPE = new _GoogleMapMercSpec(mt, tileVersion, mapCopy);
62 mapSpecs.push(_GOOGLE_MAP_TYPE);
63 if (!kdisable)
64 {
65 _SATELLITE_TYPE = new _KeyholeMapMercSpec(kmt, kdomain, ktv, khauth,kjapandatumhack);
66 mapSpecs.push(_SATELLITE_TYPE);
67 if (hybrid)
68 {
69 _HYBRID_TYPE = new _HybridMapSpec(kmt, kdomain, ktv, khauth,kjapandatumhack, hmt, hTileVersion,hybridCopy);
70 mapSpecs.push(_HYBRID_TYPE);
71 }
72 _KATRINA_TYPE = new _KatrinaMapSpec(kmt, kdomain, ktv, khauth);
73 mapSpecs.push(_KATRINA_TYPE);
74 }
75 arguments.callee.mapSpecs = mapSpecs;
76 }
77 return arguments.callee.mapSpecs;
78}
79//取得浏览器名称字符串
80var _u = navigator.userAgent.toLowerCase();
81//检查是否存在t子字符串
82function _ua(t)
83{
84 return _u.indexOf(t) != -1;
85}
86//用t作前缀解析_u,取得_u后面的城市
87function _uan(t)
88{
89 if(!window.RegExp)
90 {
91 return 0;
92 }
93 var r = new RegExp(t+'([0-9]*)');
94 var s = r.exec(_u);
95 var ret = 0;
96 if (s.length >= 2)
97 {
98 ret = s[1];
99 }
100 return ret;
101}
102//是否支持ActiveX(使用Microsoft.XMLDOM)
103function _noActiveX()
104{
105 if(!_ua('msie') || !document.all || _ua('opera'))
106 {
107 return false;
108 }
109 var s = false;
110 eval('try { new ActiveXObject("Microsoft.XMLDOM"); }'+'catch (e) { s = true; }');
111 return s;
112}
113//检查浏览器名称是否正常
114function _compat()
115{
116 return ((_ua('opera') &&(_ua('opera 7.5') || _ua('opera/7.5') ||_ua('opera 8') || _ua('opera/8'))) ||(_ua('safari') && _uan('safari/') >= 125) ||(_ua('msie') &&!_ua('msie 4') && !_ua('msie 5.0') && !_ua('msie 5.1') &&!_ua('msie 3') && !_ua('powerpc')) ||(document.getElementById && window.XSLTProcessor &&window.XMLHttpRequest && !_ua('netscape6') &&!_ua('netscape/7.0')));
117}
118//这里也比较让人费解,_compat和_browserIsCompatible、GBrowserIsCompatible其实都差不多啊
119_fc = false;
120_c = _fc || _compat();
121//返回浏览器兼容性,不知道为什么会有两个一样的函数
122function _browserIsCompatible()
123{
124 return _c;
125}
126function GBrowserIsCompatible()
127{
128 return _c;
129}
130//判断浏览器是否存在xslt解析
131function _havexslt()
132{
133 if (typeof GetObject != 'undefined' ||(typeof XMLHttpRequest != 'undefined' &&typeof DOMParser != 'undefined' &&typeof XSLTProcessor != 'undefined'))
134 {
135 return true;
136 }
137 else
138 {
139 return false;
140 }
141}
142//载入一个JS文件
143function _script(src)
144{
145 var ret='<'+'script src="'+src+'"'+' type="text/javascript"><'+'/script>';
146 document.write(ret);
147}
148//根据浏览器兼容性情况加载不同的JS文件
149function _loadMapsScript()
150{
151 if(_havexslt())
152 {
153 _script("http://maps.google.com/mapfiles/maps.21.js");
154 }
155 else if(_ua('safari'))
156 {
157 _script("http://maps.google.com/mapfiles/maps.21.safari.js");
158 }
159 else
160 {
161 _script("http://maps.google.com/mapfiles/maps.21.xslt.js");
162 }
163}
164//如果浏览器兼容并支持ActiveX,则加载JS文件
165if (_c && !_noActiveX())
166{
167 document.write('');
168 document.write('');
169 _loadMapsScript();
170}
171
2var _mZoomIn = 'Zoom In';
3var _mZoomOut = 'Zoom Out';
4var _mZoomSet = 'Click to set zoom level';
5var _mZoomDrag = 'Drag to zoom';
6var _mPanWest = 'Go left';
7var _mPanEast = 'Go right';
8var _mPanNorth = 'Go up';
9var _mPanSouth = 'Go down';
10var _mLastResult = 'Return to the last result';
11var _mGoogleCopy = '?2005 Google';
12var _mDataCopy = 'Map data ?2005 ';
13var _mNavteq = 'NAVTEQ?';
14var _mTeleAtlas = 'Tele Atlas';
15var _mZenrin = 'ZENRIN';
16var _mZenrinCopy = 'Map ?2005 ';
17var _mNormalMap = 'Map';
18var _mNormalMapShort = 'Map';
19var _mHybridMap = 'Hybrid';
20var _mHybridMapShort = 'Hyb';
21var _mNew = 'New!';
22var _mTerms = 'Terms of Use';
23var _mKeyholeMap = 'Satellite';
24var _mKeyholeMapShort = 'Sat';
25var _mKeyholeCopy = 'Imagery ?2005 ';
26var _mScale = 'Scale at the center of the map';
27var _mKilometers = 'km';
28var _mMiles = 'mi';
29var _mMeters = 'm';
30var _mFeet = 'ft';
31var _mDecimalPoint = '.';
32var _mThousandsSeparator = ',';
33var _mMapErrorTile = 'We are sorry, but we don\'t have maps at this zoom level for this region.Try zooming out for a broader look.';
34var _mKeyholeErrorTile = 'We are sorry, but we don\'t have imagery at this zoom level for this region.Try zooming out for a broader look.';
35var _mTermsURL = 'http://www.google.com/help/terms_local.html';
36var _apiHash = '5f87579ff86792cf982d095a4228e3de6cdaf562';
37var _apiKey = 'ABQIAAAA7nPTPXCvzWYxyKdmbFQfTxRfh1ef-GeSz5gtCVpCKOPebNr1YhR23M_jRfeqAugNMsW3pZQJAwfCFw';
38var _mApiBadKey = 'The Google Maps API key used on this web site was registered for a different web site. You can generate a new key for this web site at http://www.google.com/apis/maps/.';
39function createMapSpecs()
40{
41 var mt = '';
42 var tv = 'w2.5';
43 var apitv = 'w2.5';
44 var hmt = '';
45 var htv = 'w2t.1';
46 var apihtv = 'w2t.1';
47 var kmt = '';
48 var kdomain = 'google.com';
49 var ktv = '3';
50 var kdisable = false;
51 var khauth = 'fzwq2uohc9nRek9eHfZgC_oFXnYU9GSk3iYwgw';
52 var kjapandatumhack = true;
53 var hybrid = (htv != '');
54 if (!arguments.callee.mapSpecs)
55 {
56 var mapSpecs = [];
57 var tileVersion = window._apiKey ? apitv : tv;
58 var hTileVersion = window._apiKey ? apihtv : htv;
59 var mapCopy = (tileVersion != tv) ? G_MAP_API_COPYRIGHTS :G_MAP_DEFAULT_COPYRIGHTS;
60 var hybridCopy = (hTileVersion != htv) ? G_MAP_API_COPYRIGHTS :G_MAP_DEFAULT_COPYRIGHTS;
61 _GOOGLE_MAP_TYPE = new _GoogleMapMercSpec(mt, tileVersion, mapCopy);
62 mapSpecs.push(_GOOGLE_MAP_TYPE);
63 if (!kdisable)
64 {
65 _SATELLITE_TYPE = new _KeyholeMapMercSpec(kmt, kdomain, ktv, khauth,kjapandatumhack);
66 mapSpecs.push(_SATELLITE_TYPE);
67 if (hybrid)
68 {
69 _HYBRID_TYPE = new _HybridMapSpec(kmt, kdomain, ktv, khauth,kjapandatumhack, hmt, hTileVersion,hybridCopy);
70 mapSpecs.push(_HYBRID_TYPE);
71 }
72 _KATRINA_TYPE = new _KatrinaMapSpec(kmt, kdomain, ktv, khauth);
73 mapSpecs.push(_KATRINA_TYPE);
74 }
75 arguments.callee.mapSpecs = mapSpecs;
76 }
77 return arguments.callee.mapSpecs;
78}
79//取得浏览器名称字符串
80var _u = navigator.userAgent.toLowerCase();
81//检查是否存在t子字符串
82function _ua(t)
83{
84 return _u.indexOf(t) != -1;
85}
86//用t作前缀解析_u,取得_u后面的城市
87function _uan(t)
88{
89 if(!window.RegExp)
90 {
91 return 0;
92 }
93 var r = new RegExp(t+'([0-9]*)');
94 var s = r.exec(_u);
95 var ret = 0;
96 if (s.length >= 2)
97 {
98 ret = s[1];
99 }
100 return ret;
101}
102//是否支持ActiveX(使用Microsoft.XMLDOM)
103function _noActiveX()
104{
105 if(!_ua('msie') || !document.all || _ua('opera'))
106 {
107 return false;
108 }
109 var s = false;
110 eval('try { new ActiveXObject("Microsoft.XMLDOM"); }'+'catch (e) { s = true; }');
111 return s;
112}
113//检查浏览器名称是否正常
114function _compat()
115{
116 return ((_ua('opera') &&(_ua('opera 7.5') || _ua('opera/7.5') ||_ua('opera 8') || _ua('opera/8'))) ||(_ua('safari') && _uan('safari/') >= 125) ||(_ua('msie') &&!_ua('msie 4') && !_ua('msie 5.0') && !_ua('msie 5.1') &&!_ua('msie 3') && !_ua('powerpc')) ||(document.getElementById && window.XSLTProcessor &&window.XMLHttpRequest && !_ua('netscape6') &&!_ua('netscape/7.0')));
117}
118//这里也比较让人费解,_compat和_browserIsCompatible、GBrowserIsCompatible其实都差不多啊
119_fc = false;
120_c = _fc || _compat();
121//返回浏览器兼容性,不知道为什么会有两个一样的函数
122function _browserIsCompatible()
123{
124 return _c;
125}
126function GBrowserIsCompatible()
127{
128 return _c;
129}
130//判断浏览器是否存在xslt解析
131function _havexslt()
132{
133 if (typeof GetObject != 'undefined' ||(typeof XMLHttpRequest != 'undefined' &&typeof DOMParser != 'undefined' &&typeof XSLTProcessor != 'undefined'))
134 {
135 return true;
136 }
137 else
138 {
139 return false;
140 }
141}
142//载入一个JS文件
143function _script(src)
144{
145 var ret='<'+'script src="'+src+'"'+' type="text/javascript"><'+'/script>';
146 document.write(ret);
147}
148//根据浏览器兼容性情况加载不同的JS文件
149function _loadMapsScript()
150{
151 if(_havexslt())
152 {
153 _script("http://maps.google.com/mapfiles/maps.21.js");
154 }
155 else if(_ua('safari'))
156 {
157 _script("http://maps.google.com/mapfiles/maps.21.safari.js");
158 }
159 else
160 {
161 _script("http://maps.google.com/mapfiles/maps.21.xslt.js");
162 }
163}
164//如果浏览器兼容并支持ActiveX,则加载JS文件
165if (_c && !_noActiveX())
166{
167 document.write('');
168 document.write('');
169 _loadMapsScript();
170}
171
posted on 2005-09-30 17:45 K_Reverter 阅读(3016) 评论(0) 编辑 收藏 举报