@@ -1813,13 +1813,24 @@ describe('WebMapViewModel.spec', () => {
1813
1813
) ;
1814
1814
const transformed = viewModel . map . options . transformRequest ( mockTileUrl , 'Tile' ) ;
1815
1815
expect ( transformed . url ) . toMatch ( 'https://www.supermapol.com/apps/viewer/getUrlResource.png?url=' ) ;
1816
+ expect ( transformed . credentials ) . toBeUndefined ( ) ;
1816
1817
done ( ) ;
1817
1818
} ) ;
1818
1819
it ( 'add iportal map' , done => {
1819
1820
const viewModel = new WebMapViewModel ( baseLayers [ 'BAIDU' ] ) ;
1820
1821
const mockTileUrl = '' ;
1821
1822
const transformed = viewModel . map . options . transformRequest ( mockTileUrl ) ;
1822
1823
expect ( transformed . url ) . toBe ( mockTileUrl ) ;
1824
+ expect ( transformed . credentials ) . toBeUndefined ( ) ;
1825
+ done ( ) ;
1826
+ } ) ;
1827
+
1828
+ it ( 'add iportal map when url include proxy ' , done => {
1829
+ const viewModel = new WebMapViewModel ( baseLayers [ 'BAIDU' ] , { ...commonOption , proxy : proxyStr , iportalServiceProxyUrlPrefix : proxyStr } ) ;
1830
+ const mockTileUrl = `${ proxyStr } ${ encodeURIComponent ( 'http://fake.url' ) } ` ;
1831
+ const transformed = viewModel . map . options . transformRequest ( mockTileUrl , 'Tile' ) ;
1832
+ expect ( transformed . url ) . toContain ( mockTileUrl ) ;
1833
+ expect ( transformed . credentials ) . toBe ( 'include' ) ;
1823
1834
done ( ) ;
1824
1835
} ) ;
1825
1836
@@ -1865,17 +1876,27 @@ describe('WebMapViewModel.spec', () => {
1865
1876
done ( ) ;
1866
1877
} ) ;
1867
1878
it ( 'test transformRequest when proxy is string' , done => {
1868
- const viewModel = new WebMapViewModel ( '' , { ...commonOption , proxy : proxyStr } , { ...mapOptions } ) ;
1879
+ const viewModel = new WebMapViewModel ( '' , { ...commonOption , serverUrl : 'http://localhost:8080/iportal' , proxy : proxyStr } , { ...mapOptions } ) ;
1869
1880
const mockTileUrl = tiles [ 0 ] . replace ( '{x}' , 6 ) . replace ( '{y}' , 8 ) . replace ( '{z}' , 10 ) ;
1870
1881
const transformed = viewModel . mapOptions . transformRequest ( mockTileUrl , 'Tile' ) ;
1871
1882
expect ( transformed . url ) . toMatch ( proxyStr ) ;
1883
+ expect ( transformed . credentials ) . toBeUndefined ( ) ;
1884
+ done ( ) ;
1885
+ } ) ;
1886
+ it ( 'test transformRequest when url includes proxy' , done => {
1887
+ const viewModel = new WebMapViewModel ( '' , { ...commonOption , serverUrl : 'http://localhost:8080/iportal' , proxy : proxyStr } , { ...mapOptions } ) ;
1888
+ const mockTileUrl = tiles [ 0 ] . replace ( '{x}' , 6 ) . replace ( '{y}' , 8 ) . replace ( '{z}' , 10 ) ;
1889
+ const transformed = viewModel . mapOptions . transformRequest ( `${ proxyStr } ${ encodeURIComponent ( mockTileUrl ) } ` , 'Tile' ) ;
1890
+ expect ( transformed . url ) . toMatch ( proxyStr ) ;
1891
+ expect ( transformed . credentials ) . toBe ( 'include' ) ;
1872
1892
done ( ) ;
1873
1893
} ) ;
1874
1894
it ( 'test transformRequest when proxy is false' , done => {
1875
1895
const viewModel = new WebMapViewModel ( '' , { ...commonOption } , { ...mapOptions } ) ;
1876
1896
const mockTileUrl = tiles [ 0 ] . replace ( '{x}' , 6 ) . replace ( '{y}' , 8 ) . replace ( '{z}' , 10 ) ;
1877
1897
const transformed = viewModel . mapOptions . transformRequest ( mockTileUrl , 'Tile' ) ;
1878
1898
expect ( transformed . url ) . toBe ( mockTileUrl ) ;
1899
+ expect ( transformed . credentials ) . toBeUndefined ( ) ;
1879
1900
done ( ) ;
1880
1901
} ) ;
1881
1902
} ) ;
@@ -2007,4 +2028,43 @@ describe('WebMapViewModel.spec', () => {
2007
2028
const viewModel = new WebMapViewModel ( id , { ...commonOption } ) ;
2008
2029
viewModel . on ( { addlayerssucceeded : callback } ) ;
2009
2030
} ) ;
2031
+
2032
+ it ( 'markerLayer point linstring and text' , done => {
2033
+ const content = '{"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},"features":[{"type":"Feature","properties":{"dataViz_title":"","dataViz_description":"","dataViz_imgUrl":"","dataViz_url":"","dataViz_videoUrl":""},"dv_v5_markerStyle":{"strokeColor":"#0081E2","strokeOpacity":1,"strokeWidth":5,"lineCap":"round","lineDash":"solid"},"dv_v5_markerInfo":{"dataViz_title":"","dataViz_description":"","dataViz_imgUrl":"","dataViz_url":"","dataViz_videoUrl":""},"geometry":{"type":"LineString","coordinates":[[103.21230856170534,35.93252826339496],[96.80142450317665,31.772281946203208]]}},{"type":"Feature","properties":{"dataViz_title":"这是文字"},"dv_v5_markerStyle":{"text":"这是文字","font":"33px 宋体","placement":"point","textAlign":"right","fillColor":"#595959","backgroundFill":"#ee8b8b","borderColor":"rgba(255,255,255,0)","borderWidth":4,"padding":[8,8,8,8],"maxWidth":358},"dv_v5_markerInfo":{"dataViz_title":"这是文字"},"geometry":{"type":"Point","coordinates":[101.56249999999991,26.728112105878537]}},{"type":"Feature","properties":{"dataViz_title":"","dataViz_description":"","dataViz_imgUrl":"","dataViz_url":"","dataViz_videoUrl":""},"dv_v5_markerStyle":{"src":"http://172.16.14.44:8190/iportal/apps/dataviz/static/imgs/markers/mark_red.png","scale":1,"anchor":[0.5,0.5],"imgWidth":48,"imgHeight":43},"dv_v5_markerInfo":{"dataViz_title":"","dataViz_description":"","dataViz_imgUrl":"","dataViz_url":"","dataViz_videoUrl":""},"geometry":{"type":"Point","coordinates":[93.72012106170533,30.646288585669723]}},{"type":"Feature","properties":{"dataViz_title":"","dataViz_description":"","dataViz_imgUrl":"","dataViz_url":"","dataViz_videoUrl":""},"dv_v5_markerStyle":{"src":"http://172.16.14.44:8190/iportal/apps/dataviz/static/imgs/markers//ktv_red.png","scale":1,"anchor":[0.5,0.5],"imgWidth":48,"imgHeight":43},"dv_v5_markerInfo":{"dataViz_title":"","dataViz_description":"","dataViz_imgUrl":"","dataViz_url":"","dataViz_videoUrl":""},"geometry":{"type":"Point","coordinates":[95.91738668670534,35.145840549134476]}},{"type":"Feature","properties":{"dataViz_title":"","dataViz_description":"","dataViz_imgUrl":"","dataViz_url":"","dataViz_videoUrl":""},"dv_v5_markerStyle":{"radius":10,"fillColor":"#53C41A","fillOpacity":0.73,"strokeColor":"#e20057","strokeOpacity":1,"strokeWidth":4},"dv_v5_markerInfo":{"dataViz_title":"","dataViz_description":"","dataViz_imgUrl":"","dataViz_url":"","dataViz_videoUrl":""},"geometry":{"type":"Point","coordinates":[101.36660543670533,38.107643862311676]}}]}' ;
2034
+ const newLayerData_geojson = {
2035
+ ...layerData_geojson [ 'MARKER_GEOJSON' ] ,
2036
+ content
2037
+ } ;
2038
+ const contentData = JSON . parse ( content ) ;
2039
+ const fetchResource = {
2040
+ 'https://fakeiportal.supermap.io/iportal/web/datas/1795361105/content.json?pageSize=9999999¤tPage=1&parentResType=MAP&parentResId=undefined' :
2041
+ newLayerData_geojson
2042
+ } ;
2043
+ mockFetch ( fetchResource ) ;
2044
+ const layers = [ {
2045
+ layerType : 'MARKER' ,
2046
+ visible : true ,
2047
+ name : '未命名标注图层1' ,
2048
+ serverId : '1795361105'
2049
+ } ] ;
2050
+ const id = {
2051
+ ...markerLayer ,
2052
+ layers
2053
+ } ;
2054
+ const viewModel = new WebMapViewModel ( id , { ...commonOption } ) ;
2055
+ const callback = function ( data ) {
2056
+ const layersOnMap = Object . values ( data . map . overlayLayersManager ) ;
2057
+ expect ( layersOnMap . length ) . toBe ( contentData . features . length + 1 ) ;
2058
+ expect ( layersOnMap . length ) . toBe ( viewModel . _cacheLayerId . length ) ;
2059
+ const layerID = layers [ 0 ] . name ;
2060
+ const firstMarkerLayer = layersOnMap . find ( item => item . id === layerID ) ;
2061
+ expect ( firstMarkerLayer ) . toBeTruthy ( ) ;
2062
+ expect ( firstMarkerLayer . type ) . toBe ( 'line' ) ;
2063
+ expect ( layersOnMap . some ( item => item . id . includes ( `${ layerID } -LINESTRING` ) ) ) . toBeFalsy ( ) ;
2064
+ expect ( layersOnMap . some ( item => item . id . includes ( `${ layerID } -TEXT` ) ) ) . toBeTruthy ( ) ;
2065
+ expect ( layersOnMap . filter ( item => item . id . includes ( `${ layerID } -POINT-` ) ) ) . toHaveLength ( 3 ) ;
2066
+ done ( ) ;
2067
+ } ;
2068
+ viewModel . on ( { addlayerssucceeded : callback } ) ;
2069
+ } ) ;
2010
2070
} ) ;
0 commit comments