-
Notifications
You must be signed in to change notification settings - Fork 160
/
baidu.html
214 lines (177 loc) · 7.13 KB
/
baidu.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<head>
<title>BaiDu</title>
<link href="../Build/Cesium/Widgets/widgets.css" rel="stylesheet">
<script type="text/javascript" src="./js/require.min.js" data-main="./js/main"></script>
</head>
<body>
<div id="cesiumContainer"></div>
<script>
function onload(Cesium) {
///////////////////////////////////////////
function BDImageryProvider(options) {
this._url = "http://online1.map.bdimg.com/onlinelabel/?qt=tile";
this._tileWidth = 256;
this._tileHeight = 256;
this._maximumLevel = 18;
var rectangleSouthwestInMeters = new Cesium.Cartesian2(-25165824, -25165824);
var rectangleNortheastInMeters = new Cesium.Cartesian2(25165824, 25165824);
this._tilingScheme = new Cesium.WebMercatorTilingScheme({rectangleSouthwestInMeters:rectangleSouthwestInMeters,rectangleNortheastInMeters:rectangleNortheastInMeters});
//var rectangleSouthwestInMeters = new Cesium.Cartesian2(-25165824, -25165824);
//var rectangleNortheastInMeters = new Cesium.Cartesian2(25165824, 25165824);
//this._tilingScheme = new Cesium.WebMercatorTilingScheme();
this._credit = undefined;
this._rectangle = this._tilingScheme.rectangle;
this._ready = true;
}
function buildImageUrl(imageryProvider, x, y, level) {
var url = imageryProvider._url + "&x={x}&y={y}&z={z}";
var tileW = imageryProvider._tilingScheme.getNumberOfXTilesAtLevel(level);
var tileH = imageryProvider._tilingScheme.getNumberOfYTilesAtLevel(level);
url = url
.replace('{x}', x - tileW/2)
.replace('{y}', tileH/2 - y)
.replace('{z}', level);
return url;
}
Cesium.defineProperties(BDImageryProvider.prototype, {
url : {
get : function() {
return this._url;
}
},
token : {
get : function() {
return this._token;
}
},
proxy : {
get : function() {
return this._proxy;
}
},
tileWidth : {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this._ready) {
throw new DeveloperError('tileWidth must not be called before the imagery provider is ready.');
}
//>>includeEnd('debug');
return this._tileWidth;
}
},
tileHeight: {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this._ready) {
throw new DeveloperError('tileHeight must not be called before the imagery provider is ready.');
}
//>>includeEnd('debug');
return this._tileHeight;
}
},
maximumLevel : {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this._ready) {
throw new DeveloperError('maximumLevel must not be called before the imagery provider is ready.');
}
//>>includeEnd('debug');
return this._maximumLevel;
}
},
minimumLevel : {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this._ready) {
throw new DeveloperError('minimumLevel must not be called before the imagery provider is ready.');
}
//>>includeEnd('debug');
return 0;
}
},
tilingScheme : {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this._ready) {
throw new DeveloperError('tilingScheme must not be called before the imagery provider is ready.');
}
//>>includeEnd('debug');
return this._tilingScheme;
}
},
rectangle : {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this._ready) {
throw new DeveloperError('rectangle must not be called before the imagery provider is ready.');
}
//>>includeEnd('debug');
return this._rectangle;
}
},
tileDiscardPolicy : {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this._ready) {
throw new DeveloperError('tileDiscardPolicy must not be called before the imagery provider is ready.');
}
//>>includeEnd('debug');
return this._tileDiscardPolicy;
}
},
errorEvent : {
get : function() {
return this._errorEvent;
}
},
ready : {
get : function() {
return this._ready;
}
},
readyPromise : {
get : function() {
return this._readyPromise.promise;
}
},
credit : {
get : function() {
return this._credit;
}
},
usingPrecachedTiles : {
get : function() {
return this._useTiles;
}
},
hasAlphaChannel : {
get : function() {
return true;
}
},
layers : {
get : function() {
return this._layers;
}
}
});
BDImageryProvider.prototype.getTileCredits = function(x, y, level) {
return undefined;
};
BDImageryProvider.prototype.requestImage = function(x, y, level) {
if (!this._ready) {
throw new DeveloperError('requestImage must not be called before the imagery provider is ready.');
}
var url = buildImageUrl(this, x, y, level);
return Cesium.ImageryProvider.loadImage(this, url);
};
//////////////////////////////////////////////
var bdlayer = new BDImageryProvider();
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider : bdlayer,
baseLayerPicker : false
});
};
</script>
</body>