1- require ( '../../../src/classic/overlay/MapVLayer' ) ;
1+ import { MapVLayer } from '../../../src/classic/overlay/MapVLayer' ;
2+ import { Bounds } from '../../../src/common/commontypes/Bounds' ;
3+ import { LonLat } from '../../../src/common/commontypes/LonLat' ;
4+
25var mapv = require ( 'mapv' ) ;
36window . mapv = mapv ;
47
58var url = GlobeParameter . ChinaURL ;
6- describe ( 'classic_MapVLayer' , function ( ) {
9+ describe ( 'classic_MapVLayer' , ( ) => {
710 var originalTimeout ;
811 var testDiv , map , baseLayer , mapvLayer ;
9- beforeAll ( function ( ) {
12+ beforeAll ( ( ) => {
1013 testDiv = window . document . createElement ( "div" ) ;
1114 testDiv . setAttribute ( "id" , "map" ) ;
1215 testDiv . style . styleFloat = "left" ;
@@ -15,29 +18,19 @@ describe('classic_MapVLayer', function () {
1518 testDiv . style . width = "500px" ;
1619 testDiv . style . height = "500px" ;
1720 window . document . body . appendChild ( testDiv ) ;
18- map = new SuperMap . Map ( "map" , {
19- controls : [
20- new SuperMap . Control . Attribution ( ) ,
21- new SuperMap . Control . ScaleLine ( ) ,
22- new SuperMap . Control . Zoom ( ) ,
23- new SuperMap . Control . Navigation ( {
24- dragPanOptions : {
25- enableKinetic : true
26- }
27- } ) ]
28- } ) ;
21+ map = new SuperMap . Map ( "map" ) ;
2922 baseLayer = new SuperMap . Layer . TiledDynamicRESTLayer ( "China" , url , {
3023 units : "m" ,
3124 transparent : true ,
3225 cacheEnabled : true
3326 } , { maxResolution : "auto" } ) ;
34- baseLayer . events . on ( { "layerInitialized" : addLayer } ) ;
35- function addLayer ( ) {
27+ var addLayer = ( ) => {
3628 map . addLayers ( [ baseLayer ] ) ;
37- map . setCenter ( new SuperMap . LonLat ( 104 , 34.7 ) , 2 ) ;
29+ map . setCenter ( new LonLat ( 104 , 34.7 ) , 2 ) ;
3830 }
31+ baseLayer . events . on ( { "layerInitialized" : addLayer ( ) } ) ;
3932 } ) ;
40- beforeEach ( function ( ) {
33+ beforeEach ( ( ) => {
4134 //创建mapVLayer
4235 var randomCount = 1000 ;
4336 var data = [ ] ;
@@ -70,22 +63,21 @@ describe('classic_MapVLayer', function () {
7063 gradient : { 0.25 : "rgb(0,0,255)" , 0.55 : "rgb(0,255,0)" , 0.85 : "yellow" , 1.0 : "rgb(255,0,0)" } ,
7164 draw : 'honeycomb'
7265 } ;
73- mapvLayer = new SuperMap . Layer . MapVLayer ( "mapv" , { dataSet : dataSet , options : options } ) ;
66+ mapvLayer = new MapVLayer ( "mapv" , { dataSet : dataSet , options : options } ) ;
7467 map . addLayer ( mapvLayer ) ;
7568 originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
7669 jasmine . DEFAULT_TIMEOUT_INTERVAL = 50000 ;
7770 } ) ;
78- afterEach ( function ( ) {
71+ afterEach ( ( ) => {
7972 jasmine . DEFAULT_TIMEOUT_INTERVAL = originalTimeout ;
8073 mapvLayer . destroy ( ) ;
8174 } ) ;
82- afterAll ( function ( ) {
75+ afterAll ( ( ) => {
8376 document . body . removeChild ( testDiv ) ;
84- //map.destroy();
8577 mapv = null ;
8678 } ) ;
8779
88- it ( 'constructor' , function ( ) {
80+ it ( 'constructor' , ( ) => {
8981 expect ( mapvLayer ) . not . toBeNull ( ) ;
9082 expect ( mapvLayer . options . shadowBlur ) . toEqual ( 20 ) ;
9183 expect ( mapvLayer . options . draw ) . toBe ( "honeycomb" ) ;
@@ -99,7 +91,7 @@ describe('classic_MapVLayer', function () {
9991 expect ( mapvLayer . renderer . canvasLayer . minScale ) . toEqual ( 590591790 ) ;
10092 } ) ;
10193
102- it ( 'addData' , function ( ) {
94+ it ( 'addData' , ( ) => {
10395 var data = [ {
10496 geometry : {
10597 type : 'Point' ,
@@ -119,12 +111,12 @@ describe('classic_MapVLayer', function () {
119111 expect ( mapvLayer . options . shadowBlur ) . toEqual ( 30 ) ;
120112 } ) ;
121113
122- it ( 'getData' , function ( ) {
114+ it ( 'getData' , ( ) => {
123115 var dataset = mapvLayer . getData ( )
124116 expect ( dataset . _data . length ) . toEqual ( 1000 ) ;
125117 } ) ;
126118
127- it ( 'setData' , function ( ) {
119+ it ( 'setData' , ( ) => {
128120 var data = [ {
129121 geometry : {
130122 type : 'Point' ,
@@ -144,12 +136,12 @@ describe('classic_MapVLayer', function () {
144136 expect ( mapvLayer . options . shadowBlur ) . toEqual ( 40 ) ;
145137 } ) ;
146138
147- it ( 'clearData' , function ( ) {
139+ it ( 'clearData' , ( ) => {
148140 mapvLayer . clearData ( ) ;
149141 expect ( mapvLayer . dataSet . _data . length ) . toEqual ( 0 ) ;
150142 } ) ;
151143
152- it ( 'destroy' , function ( ) {
144+ it ( 'destroy' , ( ) => {
153145 mapvLayer . destroy ( ) ;
154146 expect ( mapvLayer . dataSet ) . toBeNull ( ) ;
155147 expect ( mapvLayer . options ) . toBeNull ( ) ;
@@ -161,28 +153,28 @@ describe('classic_MapVLayer', function () {
161153 } ) ;
162154
163155 //方法引用错误
164- xit ( 'removeData' , function ( done ) {
165- var filter = function ( data ) {
156+ xit ( 'removeData' , ( done ) => {
157+ var filter = ( data ) => {
166158 if ( mapvLayer . dataSet . _data . indexOf ( data ) === 2 ) {
167159 return true
168160 }
169161 return false ;
170162 }
171163 mapvLayer . removeData ( filter ) ;
172- setTimeout ( function ( ) {
164+ setTimeout ( ( ) => {
173165 expect ( mapvLayer . dataSet . _data . length ) . toEqual ( 999 ) ;
174166 done ( ) ;
175167 } , 5000 ) ;
176168 } ) ;
177169
178- xit ( 'setMap' , function ( ) {
170+ xit ( 'setMap' , ( ) => {
179171 mapvLayer . setMap ( map ) ;
180172 expect ( mapvLayer ) . not . toBeNull ( ) ;
181173 expect ( mapvLayer . dataSet . _data . length ) . toEqual ( 1000 ) ;
182174 } ) ;
183175
184- xit ( 'moveTo' , function ( ) {
185- var bounds = new SuperMap . Bounds ( - 180 , - 90 , 180 , 90 ) ;
176+ xit ( 'moveTo' , ( ) => {
177+ var bounds = new Bounds ( - 180 , - 90 , 180 , 90 ) ;
186178 mapvLayer . moveTo ( bounds , false , true ) ;
187179 expect ( mapvLayer ) . not . toBeNull ( ) ;
188180 expect ( mapvLayer . maxExtent . CLASS_NAME ) . toEqual ( "SuperMap.Bounds" ) ;
@@ -192,8 +184,8 @@ describe('classic_MapVLayer', function () {
192184 expect ( mapvLayer . maxExtent . top ) . toEqual ( 90 ) ;
193185 } ) ;
194186
195- xit ( 'transferToMapLatLng' , function ( ) {
196- var latlng = new SuperMap . LonLat ( 104 , 34.7 ) ;
187+ xit ( 'transferToMapLatLng' , ( ) => {
188+ var latlng = new LonLat ( 104 , 34.7 ) ;
197189 mapvLayer . transferToMapLatLng ( latlng ) ;
198190 expect ( mapvLayer ) . not . toBeNull ( ) ;
199191 } ) ;
0 commit comments