@@ -42,7 +42,8 @@ export class MapVRenderer extends MapVBaseLayer {
4242 */
4343 clickEvent ( e ) {
4444 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 ) ;
4647 }
4748
4849 /**
@@ -64,10 +65,10 @@ export class MapVRenderer extends MapVBaseLayer {
6465
6566 if ( this . options . methods ) {
6667 if ( this . options . methods . click ) {
67- map . events . on ( { ' click' : this . clickEvent } ) ;
68+ map . events . on ( { click : this . clickEvent } ) ;
6869 }
6970 if ( this . options . methods . mousemove ) {
70- map . events . on ( { ' mousemove' : this . mousemoveEvent } ) ;
71+ map . events . on ( { mousemove : this . mousemoveEvent } ) ;
7172 }
7273 }
7374 }
@@ -81,10 +82,10 @@ export class MapVRenderer extends MapVBaseLayer {
8182
8283 if ( this . options . methods ) {
8384 if ( this . options . methods . click ) {
84- map . events . un ( { ' click' : this . clickEvent } ) ;
85+ map . events . un ( { click : this . clickEvent } ) ;
8586 }
8687 if ( this . options . methods . mousemove ) {
87- map . events . un ( { ' mousemove' : this . mousemoveEvent } ) ;
88+ map . events . un ( { mousemove : this . mousemoveEvent } ) ;
8889 }
8990 }
9091 }
@@ -109,7 +110,7 @@ export class MapVRenderer extends MapVBaseLayer {
109110 _data = data . get ( ) ;
110111 }
111112 this . dataSet . add ( _data ) ;
112- this . update ( { options : options } ) ;
113+ this . update ( { options : options } ) ;
113114 }
114115
115116 /**
@@ -125,7 +126,7 @@ export class MapVRenderer extends MapVBaseLayer {
125126 }
126127 this . dataSet = this . dataSet || new DataSet ( ) ;
127128 this . dataSet . set ( _data ) ;
128- this . update ( { options : options } ) ;
129+ this . update ( { options : options } ) ;
129130 }
130131
131132 /**
@@ -147,11 +148,11 @@ export class MapVRenderer extends MapVBaseLayer {
147148 }
148149 var newData = this . dataSet . get ( {
149150 filter : function ( data ) {
150- return ( filter != null && typeof filter === " function" ) ? ! filter ( data ) : true ;
151+ return filter != null && typeof filter === ' function' ? ! filter ( data ) : true ;
151152 }
152153 } ) ;
153154 this . dataSet . set ( newData ) ;
154- this . update ( { options : null } ) ;
155+ this . update ( { options : null } ) ;
155156 }
156157
157158 /**
@@ -160,7 +161,7 @@ export class MapVRenderer extends MapVBaseLayer {
160161 */
161162 clearData ( ) {
162163 this . dataSet && this . dataSet . clear ( ) ;
163- this . update ( { options : null } ) ;
164+ this . update ( { options : null } ) ;
164165 }
165166
166167 /**
@@ -178,15 +179,24 @@ export class MapVRenderer extends MapVBaseLayer {
178179 * @deprecated
179180 */
180181 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 ) {
182183 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+ ) ;
190200 this . dataSet . _set ( data ) ;
191201 }
192202 }
@@ -226,15 +236,18 @@ export class MapVRenderer extends MapVBaseLayer {
226236 context . clear ( context . COLOR_BUFFER_BIT ) ;
227237 }
228238
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+ ) {
230243 return ;
231244 }
232245 var layer = self . canvasLayer ;
246+
233247 var dataGetOptions = {
234248 fromColumn : 'coordinates' ,
235249 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 ] } ;
238251 var worldPoint = map . getViewPortPxFromLonLat ( coord ) ;
239252 return [ worldPoint . x , worldPoint . y ] ;
240253 }
@@ -243,8 +256,8 @@ export class MapVRenderer extends MapVBaseLayer {
243256 if ( time !== undefined ) {
244257 dataGetOptions . filter = function ( item ) {
245258 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+ } ;
248261 }
249262
250263 var data = self . dataSet . get ( dataGetOptions ) ;
@@ -276,9 +289,7 @@ export class MapVRenderer extends MapVBaseLayer {
276289 self . options . updateCallback && self . options . updateCallback ( time ) ;
277290 }
278291
279-
280292 init ( options ) {
281-
282293 var self = this ;
283294
284295 self . options = options ;
@@ -299,8 +310,8 @@ export class MapVRenderer extends MapVBaseLayer {
299310 * @description 添加动画事件。
300311 */
301312 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 ) } ) ;
304315 }
305316
306317 /**
@@ -328,7 +339,6 @@ export class MapVRenderer extends MapVBaseLayer {
328339 this . map . removeLayer ( this . canvasLayer ) ;
329340 }
330341
331-
332342 /**
333343 * @function MapvRenderer.prototype.draw
334344 * @description 渲染绘制。
0 commit comments