@@ -42,7 +42,8 @@ export class MapVRenderer extends MapVBaseLayer {
42
42
*/
43
43
clickEvent ( e ) {
44
44
var pixel = e . xy ;
45
- super . clickEvent ( pixel , e ) ;
45
+ var devicePixelRatio = this . devicePixelRatio || 1 ;
46
+ super . clickEvent ( { x : pixel . x / devicePixelRatio , y : pixel . y / devicePixelRatio } , e ) ;
46
47
}
47
48
48
49
/**
@@ -64,10 +65,10 @@ export class MapVRenderer extends MapVBaseLayer {
64
65
65
66
if ( this . options . methods ) {
66
67
if ( this . options . methods . click ) {
67
- map . events . on ( { ' click' : this . clickEvent } ) ;
68
+ map . events . on ( { click : this . clickEvent } ) ;
68
69
}
69
70
if ( this . options . methods . mousemove ) {
70
- map . events . on ( { ' mousemove' : this . mousemoveEvent } ) ;
71
+ map . events . on ( { mousemove : this . mousemoveEvent } ) ;
71
72
}
72
73
}
73
74
}
@@ -81,10 +82,10 @@ export class MapVRenderer extends MapVBaseLayer {
81
82
82
83
if ( this . options . methods ) {
83
84
if ( this . options . methods . click ) {
84
- map . events . un ( { ' click' : this . clickEvent } ) ;
85
+ map . events . un ( { click : this . clickEvent } ) ;
85
86
}
86
87
if ( this . options . methods . mousemove ) {
87
- map . events . un ( { ' mousemove' : this . mousemoveEvent } ) ;
88
+ map . events . un ( { mousemove : this . mousemoveEvent } ) ;
88
89
}
89
90
}
90
91
}
@@ -109,7 +110,7 @@ export class MapVRenderer extends MapVBaseLayer {
109
110
_data = data . get ( ) ;
110
111
}
111
112
this . dataSet . add ( _data ) ;
112
- this . update ( { options : options } ) ;
113
+ this . update ( { options : options } ) ;
113
114
}
114
115
115
116
/**
@@ -125,7 +126,7 @@ export class MapVRenderer extends MapVBaseLayer {
125
126
}
126
127
this . dataSet = this . dataSet || new DataSet ( ) ;
127
128
this . dataSet . set ( _data ) ;
128
- this . update ( { options : options } ) ;
129
+ this . update ( { options : options } ) ;
129
130
}
130
131
131
132
/**
@@ -147,11 +148,11 @@ export class MapVRenderer extends MapVBaseLayer {
147
148
}
148
149
var newData = this . dataSet . get ( {
149
150
filter : function ( data ) {
150
- return ( filter != null && typeof filter === " function" ) ? ! filter ( data ) : true ;
151
+ return filter != null && typeof filter === ' function' ? ! filter ( data ) : true ;
151
152
}
152
153
} ) ;
153
154
this . dataSet . set ( newData ) ;
154
- this . update ( { options : null } ) ;
155
+ this . update ( { options : null } ) ;
155
156
}
156
157
157
158
/**
@@ -160,7 +161,7 @@ export class MapVRenderer extends MapVBaseLayer {
160
161
*/
161
162
clearData ( ) {
162
163
this . dataSet && this . dataSet . clear ( ) ;
163
- this . update ( { options : null } ) ;
164
+ this . update ( { options : null } ) ;
164
165
}
165
166
166
167
/**
@@ -178,15 +179,24 @@ export class MapVRenderer extends MapVBaseLayer {
178
179
* @deprecated
179
180
*/
180
181
transferToMercator ( ) {
181
- if ( this . options . coordType && [ " bd09mc" , " coordinates_mercator" ] . indexOf ( this . options . coordType ) > - 1 ) {
182
+ if ( this . options . coordType && [ ' bd09mc' , ' coordinates_mercator' ] . indexOf ( this . options . coordType ) > - 1 ) {
182
183
var data = this . dataSet . get ( ) ;
183
- data = this . dataSet . transferCoordinate ( data , function ( coordinates ) {
184
- var pixel = SuperMap . Projection . transform ( {
185
- x : coordinates [ 0 ] ,
186
- y : coordinates [ 1 ]
187
- } , "EPSG:3857" , "EPSG:4326" ) ;
188
- return [ pixel . x , pixel . y ] ;
189
- } , 'coordinates' , 'coordinates' ) ;
184
+ data = this . dataSet . transferCoordinate (
185
+ data ,
186
+ function ( coordinates ) {
187
+ var pixel = SuperMap . Projection . transform (
188
+ {
189
+ x : coordinates [ 0 ] ,
190
+ y : coordinates [ 1 ]
191
+ } ,
192
+ 'EPSG:3857' ,
193
+ 'EPSG:4326'
194
+ ) ;
195
+ return [ pixel . x , pixel . y ] ;
196
+ } ,
197
+ 'coordinates' ,
198
+ 'coordinates'
199
+ ) ;
190
200
this . dataSet . _set ( data ) ;
191
201
}
192
202
}
@@ -226,15 +236,18 @@ export class MapVRenderer extends MapVBaseLayer {
226
236
context . clear ( context . COLOR_BUFFER_BIT ) ;
227
237
}
228
238
229
- if ( self . options . minZoom && map . getZoom ( ) < self . options . minZoom || self . options . maxZoom && map . getZoom ( ) > self . options . maxZoom ) {
239
+ if (
240
+ ( self . options . minZoom && map . getZoom ( ) < self . options . minZoom ) ||
241
+ ( self . options . maxZoom && map . getZoom ( ) > self . options . maxZoom )
242
+ ) {
230
243
return ;
231
244
}
232
245
var layer = self . canvasLayer ;
246
+
233
247
var dataGetOptions = {
234
248
fromColumn : 'coordinates' ,
235
249
transferCoordinate : function ( coordinate ) {
236
- // var coord = layer.transferToMapLatLng({lon: coordinate[0], lat: coordinate[1]});
237
- var coord = { lon : coordinate [ 0 ] , lat : coordinate [ 1 ] } ;
250
+ var coord = { lon : coordinate [ 0 ] , lat : coordinate [ 1 ] } ;
238
251
var worldPoint = map . getViewPortPxFromLonLat ( coord ) ;
239
252
return [ worldPoint . x , worldPoint . y ] ;
240
253
}
@@ -243,8 +256,8 @@ export class MapVRenderer extends MapVBaseLayer {
243
256
if ( time !== undefined ) {
244
257
dataGetOptions . filter = function ( item ) {
245
258
var trails = animationOptions . trails || 10 ;
246
- return ( time && item . time > ( time - trails ) && item . time < time ) ;
247
- }
259
+ return time && item . time > time - trails && item . time < time ;
260
+ } ;
248
261
}
249
262
250
263
var data = self . dataSet . get ( dataGetOptions ) ;
@@ -276,9 +289,7 @@ export class MapVRenderer extends MapVBaseLayer {
276
289
self . options . updateCallback && self . options . updateCallback ( time ) ;
277
290
}
278
291
279
-
280
292
init ( options ) {
281
-
282
293
var self = this ;
283
294
284
295
self . options = options ;
@@ -299,8 +310,8 @@ export class MapVRenderer extends MapVBaseLayer {
299
310
* @description 添加动画事件。
300
311
*/
301
312
addAnimatorEvent ( ) {
302
- this . map . events . on ( { ' movestart' : this . animatorMovestartEvent . bind ( this ) } ) ;
303
- this . map . events . on ( { ' moveend' : this . animatorMoveendEvent . bind ( this ) } ) ;
313
+ this . map . events . on ( { movestart : this . animatorMovestartEvent . bind ( this ) } ) ;
314
+ this . map . events . on ( { moveend : this . animatorMoveendEvent . bind ( this ) } ) ;
304
315
}
305
316
306
317
/**
@@ -328,7 +339,6 @@ export class MapVRenderer extends MapVBaseLayer {
328
339
this . map . removeLayer ( this . canvasLayer ) ;
329
340
}
330
341
331
-
332
342
/**
333
343
* @function MapvRenderer.prototype.draw
334
344
* @description 渲染绘制。
0 commit comments