FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
iClient-JavaScript/test/tool/mock_l7.js at master · SuperMap/iClient-JavaScript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
SuperMap
/
iClient-JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
288
Star
906
Code
Issues
5
Pull requests
14
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
iClient-JavaScript
/
test
/
tool
/
mock_l7.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
265 lines (253 loc) · 5.79 KB
Breadcrumbs
iClient-JavaScript
/
test
/
tool
/
mock_l7.js
Copy path
File metadata and controls
265 lines (253 loc) · 5.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
if
(
!
Array
.
prototype
.
at
)
{
Object
.
defineProperty
(
Array
.
prototype
,
'at'
,
{
value
:
function
at
(
index
)
{
// 1. 让 O 成为 ToObject(this)
if
(
this
==
null
)
{
throw
new
TypeError
(
'Cannot convert undefined or null to object'
)
;
}
var
O
=
Object
(
this
)
;
// 2. 让 len 成为 ToLength(O.length)
var
len
=
O
.
length
>>>
0
;
// 3. 让 relativeIndex 成为 ToInteger(index)
var
relativeIndex
=
Math
.
trunc
(
index
)
||
0
;
// 如果参数是 NaN,Math.trunc(NaN) 是 NaN,NaN || 0 会将其变成 0
// 这符合标准(规范中 ToIntegerOrInfinity(undefined) 结果为 0)
// 4. 计算实际索引
var
k
=
relativeIndex
>=
0
?
relativeIndex
:
len
+
relativeIndex
;
// 5. 边界检查:如果超出范围,返回 undefined
if
(
k
<
0
||
k
>=
len
)
{
return
undefined
;
}
// 6. 返回对应的属性值
return
O
[
k
]
;
}
,
writable
:
true
,
configurable
:
true
}
)
;
}
class
Event
{
constructor
(
)
{
this
.
stacks
=
{
}
;
}
on
(
type
,
cb
)
{
this
.
stacks
[
type
]
=
this
.
stacks
[
type
]
||
[
]
;
this
.
stacks
[
type
]
.
push
(
cb
)
;
}
emit
(
type
)
{
this
.
stacks
[
type
]
?.
forEach
(
(
cb
)
=>
{
cb
(
)
;
}
)
;
}
}
const
event
=
new
Event
(
)
;
class
Scene
{
constructor
(
)
{
this
.
layerService
=
{
renderLayer
:
(
)
=>
{
}
,
stopAnimate
:
(
)
=>
true
,
startAnimate
:
(
)
=>
true
}
;
this
.
callbacks
=
{
}
;
event
.
stacks
=
{
}
;
}
removeAllLayer
(
)
{
}
getLayer
(
)
{
return
true
;
}
addLayer
(
)
{
setTimeout
(
(
)
=>
{
event
.
emit
(
're-render'
)
;
}
,
100
)
;
return
true
;
}
removeLayer
(
)
{
return
true
;
}
on
(
type
,
callback
)
{
this
.
callbacks
[
type
]
=
callback
;
callback
(
)
;
}
emit
(
type
)
{
this
.
callbacks
[
type
]
(
)
;
}
addMarkerLayer
(
)
{
return
true
;
}
removeMarkerLayer
(
)
{
return
true
;
}
addImage
(
)
{
return
true
;
}
hasImage
(
)
{
return
false
;
}
}
const
Mapbox
=
(
{
mapInstance
}
)
=>
{
return
mapInstance
;
}
;
const
Maplibre
=
(
{
mapInstance
}
)
=>
{
return
mapInstance
;
}
;
class
Layer
{
constructor
(
options
)
{
this
.
animateStatus
=
false
;
this
.
layerModel
=
{
spriteAnimate
:
false
}
;
this
.
rawConfig
=
options
;
this
.
layerSource
=
{
originData
:
{
type
:
'FeatureCollection'
,
features
:
[
]
}
,
data
:
{
dataArray
:
[
]
}
}
;
this
.
pickingService
=
{
handleRawFeature
:
function
(
rawFeature
)
{
rawFeature
=
rawFeature
instanceof
Array
?
rawFeature
:
[
rawFeature
]
;
const
res
=
rawFeature
.
map
(
(
item
)
=>
{
if
(
item
===
'null'
)
{
return
item
;
}
if
(
item
.
type
===
'Feature'
)
{
return
item
;
}
const
newFeature
=
{
properties
:
{
}
,
geometry
:
{
type
:
''
,
coordinates
:
[
]
}
}
;
const
coordinates
=
item
.
coordinates
;
delete
item
.
coordinates
;
newFeature
.
properties
=
item
;
if
(
coordinates
)
{
newFeature
.
geometry
=
{
type
:
''
,
coordinates
}
;
}
return
newFeature
;
}
)
;
return
res
;
}
}
;
}
source
(
data
,
options
=
{
}
)
{
const
parser
=
options
.
parser
||
{
type
:
'geojson'
}
;
let
dataArray
=
[
]
;
if
(
parser
.
type
===
'geojson'
)
{
dataArray
=
data
;
}
if
(
parser
.
type
===
'json'
)
{
dataArray
=
[
{
航班有效期结束
:
2016.11
,
到达城市
:
'北京'
,
smpid
:
1
,
coordinates
:
[
[
80.30091874
,
41.26940127
]
,
[
116.395645
,
39.92998578
]
]
}
]
;
}
this
.
layerSource
=
{
...
options
,
parser
,
originData
:
data
.
features
?
data
:
{
type
:
'FeatureCollection'
,
features
:
data
}
,
data
:
{
dataArray
:
parser
.
type
===
'geojson'
?
data
:
[
]
}
}
;
if
(
parser
.
type
===
'mvt'
)
{
this
.
layerSource
.
tileset
=
{
cacheTiles
:
this
.
rawConfig
.
name
.
includes
(
'empty'
)
?
new
Map
(
)
:
new
Map
(
[
[
'0'
,
{
data
:
{
vectorLayerCache
:
{
[
options
.
sourceLayer
]
:
[
{
properties
:
{
}
}
]
}
}
}
]
]
)
,
isLoaded
:
false
}
;
}
return
this
;
}
style
(
)
{
return
this
;
}
animate
(
arg
)
{
this
.
animateStatus
=
arg
;
return
this
;
}
size
(
)
{
return
this
;
}
color
(
)
{
return
this
;
}
texture
(
)
{
return
this
;
}
filter
(
field
,
values
)
{
if
(
typeof
values
===
'function'
)
{
values
(
[
]
)
;
}
return
this
;
}
shape
(
type
)
{
this
.
shape
=
type
;
if
(
this
.
shape
===
'sprite'
)
{
this
.
layerModel
=
{
spriteAnimate
:
true
}
;
}
return
this
;
}
active
(
)
{
return
this
;
}
show
(
)
{
this
.
rawConfig
.
visible
=
true
;
return
this
;
}
hide
(
)
{
this
.
rawConfig
.
visible
=
false
;
return
this
;
}
getSource
(
)
{
const
sourceInfo
=
event
;
sourceInfo
.
_data
=
this
.
layerSource
.
originData
;
sourceInfo
.
getData
=
(
)
=>
this
.
layerSource
.
originData
;
sourceInfo
.
setData
=
this
.
setData
;
return
sourceInfo
;
}
setData
(
data
)
{
this
.
layerSource
.
originData
=
data
;
this
.
getSource
(
)
.
emit
(
'update'
)
;
}
on
(
type
,
cb
)
{
event
.
on
(
type
,
cb
)
;
}
once
(
)
{
}
off
(
)
{
}
boxSelect
(
bbox
,
cb
)
{
if
(
this
.
layerSource
.
originData
.
features
instanceof
Array
)
{
return
cb
(
this
.
layerSource
.
originData
.
features
)
;
}
if
(
!
(
this
.
layerSource
.
originData
instanceof
Array
)
)
{
return
cb
(
)
;
}
return
cb
(
this
.
layerSource
.
originData
)
;
}
isVisible
(
)
{
return
this
.
rawConfig
.
visible
!==
false
;
}
}
const
PointLayer
=
Layer
;
const
GeometryLayer
=
Layer
;
const
HeatmapLayer
=
Layer
;
export
{
PointLayer
,
GeometryLayer
,
HeatmapLayer
,
Scene
,
Mapbox
,
Maplibre
}
;
Back
|
FazBrowse Home
|
New Git URL