Skip to content

Commit 098e9a2

Browse files
committed
【UT】add UT
1 parent fda8998 commit 098e9a2

File tree

5 files changed

+142
-4
lines changed

5 files changed

+142
-4
lines changed

examples/mapboxgl/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ var exampleConfig = {
615615
version: '11.2.0',
616616
content: [
617617
{
618-
name: '白膜',
618+
name: '白模',
619619
name_en: 'Fill Extrusion',
620620
version: '11.2.0',
621621
thumbnail: 'iPortalWebmap_mapstudio.png',

examples/maplibregl/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ var exampleConfig = {
577577
version: '11.3.0',
578578
content: [
579579
{
580-
name: '白膜',
580+
name: '白模',
581581
name_en: 'Fill Extrusion',
582582
version: '11.3.0',
583583
thumbnail: 'iPortalWebmap_mapstudio.png',

src/openlayers/mapping/WebMap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { StyleUtils } from '../core/StyleUtils';
1616
import { TileSuperMapRest, Tianditu, BaiduMap } from '../mapping';
1717
import { VectorTileSuperMapRest, Graphic as GraphicSource, MapboxStyles, OverlayGraphic } from '../overlay';
1818
import { DataFlowService } from '../services';
19+
import cloneDeep from 'lodash.clonedeep';
1920

2021
import SampleDataInfo from './webmap/config/SampleDataInfo.json'; // eslint-disable-line import/extensions
2122

@@ -2580,7 +2581,7 @@ export class WebMap extends Observable {
25802581
}
25812582
//todo 需提示忽略无效数据
25822583
if (feature) {
2583-
let newFeature = window.cloneDeep(feature);
2584+
let newFeature = (window.cloneDeep || cloneDeep)(feature);
25842585
newFeature.properties = {};
25852586
row.forEach((item, idx) => {
25862587
//空格问题,看见DV多处处理空格问题,TODO统一整理
@@ -2616,6 +2617,7 @@ export class WebMap extends Observable {
26162617
if (allFeatures[i].geometry.type === 'Point') {
26172618
// 标注图层 还没有属性值时候不加
26182619
if (allFeatures[i].properties) {
2620+
26192621
allFeatures[i].properties.lon = coordinate[0];
26202622
allFeatures[i].properties.lat = coordinate[1];
26212623
}

test/openlayers/mapping/WebMapSpec.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,4 +1602,34 @@ describe('openlayers_WebMap', () => {
16021602
console.log(error);
16031603
}
16041604
});
1605+
it('administrativeInfoMap', (done) => {
1606+
window.MunicipalData = {
1607+
features: [{
1608+
geometry: {
1609+
coordinates: [[[[113.5872766800001, 22.16493972869857], [113.5980630750001, 22.13509586869991]]], [[[113.5511133950001, 22.21679186869615], [113.5623058550001, 22.1994578386969]]]],
1610+
type: 'MultiPolygon'
1611+
},
1612+
properties: { Name: '哈尔滨市', UserID: 0 },
1613+
type: 'Feature'
1614+
}]
1615+
}
1616+
spyOn(FetchRequest, 'get').and.callFake((url, params, options) => {
1617+
if (url.indexOf('map.json') > -1) {
1618+
var mapJson = administrativeInfoMap;
1619+
return Promise.resolve(new Response(JSON.stringify(mapJson)));
1620+
} else if (url.indexOf('650203') > -1) {
1621+
return Promise.resolve(new Response(JSON.stringify(csv_city_nogeo)));
1622+
}
1623+
return Promise.resolve();
1624+
});
1625+
var datavizWebmap = new WebMap(id, {successCallback, errorCallback, server});
1626+
function successCallback(map, mapInfo, layers, baseLayer){
1627+
expect(map.getLayers().getArray()[1].getSource().getFeatures()[0].get('attributes')['Name']).toBe('哈尔滨');
1628+
expect(map.getLayers().getArray()[1].getSource().getFeatures()[0].getGeometry()).not.toBeNull();
1629+
done();
1630+
}
1631+
function errorCallback(error) {
1632+
console.log(error);
1633+
}
1634+
});
16051635
});

test/resources/WebMapV5.js

Lines changed: 107 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)