diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index 42ef89df1c..8c870ac043 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -36,6 +36,9 @@ module.exports = ({ config }) => { loader: 'svg-inline-loader' } ); + config.resolve.alias = { + '@antv/l7-district': path.resolve(__dirname, '../packages/boundry/src'), + } config.resolve.extensions.push('.ts', '.tsx', 'css', '.js', '.glsl'); diff --git a/gatsby-node.js b/gatsby-node.js index 41bdb3a039..1069440099 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -21,6 +21,6 @@ exports.onCreateWebpackConfig = ({ getConfig }) => { '@antv/l7-utils': path.resolve(__dirname, 'packages/utils/src'), '@antv/l7-react': path.resolve(__dirname, 'packages/react/src'), '@antv/l7-draw': path.resolve(__dirname, 'packages/draw/src'), - '@antv/l7-district': path.resolve(__dirname, 'packages/district/src') + '@antv/l7-district': path.resolve(__dirname, 'packages/boundry/src') }; }; diff --git a/jest.config.js b/jest.config.js index c775c0eda8..39e29a7b29 100644 --- a/jest.config.js +++ b/jest.config.js @@ -28,7 +28,7 @@ module.exports = { moduleFileExtensions: [ 'ts', 'tsx', 'js' ], modulePathIgnorePatterns: [ 'dist' ], moduleNameMapper: { - '@antv/l7-(.+)$': 'packages/$1/src', + '@antv/l7-(.+)$': 'packages/$1/src' }, notify: true, notifyMode: 'always', diff --git a/packages/district/README.md b/packages/boundry/README.md similarity index 100% rename from packages/district/README.md rename to packages/boundry/README.md diff --git a/packages/district/__tests__/layer.spec.ts b/packages/boundry/__tests__/layer.spec.ts similarity index 100% rename from packages/district/__tests__/layer.spec.ts rename to packages/boundry/__tests__/layer.spec.ts diff --git a/packages/district/package.json b/packages/boundry/package.json similarity index 100% rename from packages/district/package.json rename to packages/boundry/package.json diff --git a/packages/district/rollup.config.js b/packages/boundry/rollup.config.js similarity index 100% rename from packages/district/rollup.config.js rename to packages/boundry/rollup.config.js diff --git a/packages/district/src/config.ts b/packages/boundry/src/config.ts similarity index 96% rename from packages/district/src/config.ts rename to packages/boundry/src/config.ts index f5c02c9b47..e68a4a8407 100644 --- a/packages/district/src/config.ts +++ b/packages/boundry/src/config.ts @@ -1,8 +1,8 @@ // tslint:disable-next-line:no-submodule-imports import merge from 'lodash/merge'; -let DataLevel = 1; -const dataLevel1: { [key: string]: any } = { +let DataLevel = 2; +const dataLevel2: { [key: string]: any } = { world: { fill: { type: 'pbf', @@ -122,7 +122,7 @@ const dataLevel1: { [key: string]: any } = { 110000: '', }, }; -const dataLevel2: { [key: string]: any } = { +const dataLevel1: { [key: string]: any } = { world: { fill: { type: 'pbf', @@ -181,12 +181,12 @@ const dataLevel2: { [key: string]: any } = { line: { type: 'pbf', url: - '//gw.alipayobjects.com/os/bmw-prod/8bfbfe7e-bd0e-4bbe-84d8-629f4dc7abc4.bin', + '//gw.alipayobjects.com/os/bmw-prod/561e2cfe-9460-42d1-a2f8-3fd2e1274c52.bin', }, cityLine: { type: 'pbf', url: - '//gw.alipayobjects.com/os/bmw-prod/8bfbfe7e-bd0e-4bbe-84d8-629f4dc7abc4.bin', + '//gw.alipayobjects.com/os/bmw-prod/561e2cfe-9460-42d1-a2f8-3fd2e1274c52.bin', }, provinceLine: { type: 'pbf', @@ -244,7 +244,7 @@ const dataLevel2: { [key: string]: any } = { }; const DataLevelMap: { [key: string]: any } = { - 1: dataLevel1, + 1: dataLevel1, // 高精度数据 2: dataLevel2, }; diff --git a/packages/district/src/index.ts b/packages/boundry/src/index.ts similarity index 100% rename from packages/district/src/index.ts rename to packages/boundry/src/index.ts diff --git a/packages/district/src/layer/baseLayer.ts b/packages/boundry/src/layer/baseLayer.ts similarity index 99% rename from packages/district/src/layer/baseLayer.ts rename to packages/boundry/src/layer/baseLayer.ts index cefef4dcab..6488c08bdd 100644 --- a/packages/district/src/layer/baseLayer.ts +++ b/packages/boundry/src/layer/baseLayer.ts @@ -312,7 +312,9 @@ export default class BaseLayer extends EventEmitter { }); popupLayer.on(popup.closeTriggerEvent as string, (e) => { - this.popup.remove(); + if (this.popup) { + this.popup.remove(); + } }); } diff --git a/packages/district/src/layer/city.ts b/packages/boundry/src/layer/city.ts similarity index 100% rename from packages/district/src/layer/city.ts rename to packages/boundry/src/layer/city.ts diff --git a/packages/district/src/layer/country.ts b/packages/boundry/src/layer/country.ts similarity index 98% rename from packages/district/src/layer/country.ts rename to packages/boundry/src/layer/country.ts index a282ddced9..f8a8eb3db5 100644 --- a/packages/district/src/layer/country.ts +++ b/packages/boundry/src/layer/country.ts @@ -16,10 +16,10 @@ export default class CountryLayer extends BaseLayer { this.addProvinceLine(countryConfig.provinceLine); if (depth === 2 * 1) { - this.addCityBorder(countryConfig.cityLine); + this.addCityBorder(countryConfig.fill); } if (depth === 3 * 1) { - this.addCountyBorder(countryConfig.countryLine); + this.addCountyBorder(countryConfig.fill); } } protected async addProvinceFill() { diff --git a/packages/district/src/layer/county.ts b/packages/boundry/src/layer/county.ts similarity index 100% rename from packages/district/src/layer/county.ts rename to packages/boundry/src/layer/county.ts diff --git a/packages/district/src/layer/drillDown.ts b/packages/boundry/src/layer/drillDown.ts similarity index 100% rename from packages/district/src/layer/drillDown.ts rename to packages/boundry/src/layer/drillDown.ts diff --git a/packages/district/src/layer/interface.ts b/packages/boundry/src/layer/interface.ts similarity index 100% rename from packages/district/src/layer/interface.ts rename to packages/boundry/src/layer/interface.ts diff --git a/packages/district/src/layer/province.ts b/packages/boundry/src/layer/province.ts similarity index 100% rename from packages/district/src/layer/province.ts rename to packages/boundry/src/layer/province.ts diff --git a/packages/district/src/layer/world.ts b/packages/boundry/src/layer/world.ts similarity index 100% rename from packages/district/src/layer/world.ts rename to packages/boundry/src/layer/world.ts diff --git a/packages/district/tsconfig.build.json b/packages/boundry/tsconfig.build.json similarity index 100% rename from packages/district/tsconfig.build.json rename to packages/boundry/tsconfig.build.json diff --git a/packages/district/src/config_1.ts b/packages/district/src/config_1.ts deleted file mode 100644 index df8043f644..0000000000 --- a/packages/district/src/config_1.ts +++ /dev/null @@ -1,128 +0,0 @@ -// tslint:disable-next-line:no-submodule-imports -import merge from 'lodash/merge'; -let DataConfig: { [key: string]: any } = { - world: { - fill: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/d666a08d-fce1-48e2-913a-87d81772bcc9.bin', - }, - line: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/62f61f5f-cca7-4137-845d-13c8f9969664.bin', - }, - label: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/90c51eb3-04d7-402f-bd05-95e4bd27dd62.bin', - parser: { - type: 'geojson', - }, - }, - nationalBoundaries: { - type: 'json', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/ee493a41-0558-4c0e-bee6-520276c4f1a8.json', - }, - }, - country: { - CHN: { - 1: { - fill: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/25228941-b2ac-4591-b07d-8261ac08d06f.bin', - }, - line: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/70ec087e-c48a-4b76-8825-6452f17bae7a.bin', - }, - provinceLine: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/0024caaf-86b2-4e75-a3d1-6d2146490b67.bin', - }, - label: { - type: 'json', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/36832a45-68f8-4b51-b006-9dec71f92a23.json', - }, - }, - 2: { - fill: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/522c6496-c711-4581-88db-c3741cd39abd.bin', - }, - line: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/f6a4e2b1-359b-43a6-921c-39d2088d1dab.bin', - }, - cityLine: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/f6a4e2b1-359b-43a6-921c-39d2088d1dab.bin', - }, - provinceLine: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/0024caaf-86b2-4e75-a3d1-6d2146490b67.bin', - }, - }, - 3: { - fill: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/516b2703-d692-44e6-80dd-b3f5df0186e7.bin', - }, - line: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/bc97875a-90f2-42c0-a62c-43d2efd7460d.bin', - }, - countryLine: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/bc97875a-90f2-42c0-a62c-43d2efd7460d.bin', - }, - cityLine: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/8bfbfe7e-bd0e-4bbe-84d8-629f4dc7abc4.bin', - }, - provinceLine: { - type: 'pbf', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/778ad7ba-5a3f-4ed6-a94a-b8ab8acae9d6.bin', - }, - }, - nationalBoundaries: { - type: 'json', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/ee493a41-0558-4c0e-bee6-520276c4f1a8.json', - }, - nationalBoundaries2: { - type: 'json', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/f2189cc4-662b-4358-8573-36f0f918b7ca.json', - }, - island: { - type: 'json', - url: - 'https://gw.alipayobjects.com/os/bmw-prod/fe49b393-1147-4769-94ed-70471f4ff15d.json', - }, - }, - }, - province: { - 110000: '', - }, -}; - -function setDataConfig(config: any) { - DataConfig = merge(DataConfig, config); -} - -export { setDataConfig, DataConfig }; diff --git a/stories/District/Layer/country_bubble.tsx b/stories/District/Layer/country_bubble.tsx index 77179ad511..e1945d9c61 100644 --- a/stories/District/Layer/country_bubble.tsx +++ b/stories/District/Layer/country_bubble.tsx @@ -209,7 +209,7 @@ export default class Country extends React.Component { }, popup: { enable: true, - Html: (props) => { + Html: (props: any) => { return `${props.NAME_CHN}:${props.value}`; }, }, diff --git a/stories/District/Layer/country_city.tsx b/stories/District/Layer/country_city.tsx index 35d45d1373..0b37ee7e62 100644 --- a/stories/District/Layer/country_city.tsx +++ b/stories/District/Layer/country_city.tsx @@ -45,7 +45,7 @@ export default class Country extends React.Component { }, popup: { enable: true, - Html: (props) => { + Html: (props: any) => { return `${props.NAME_CHN}`; }, }, diff --git a/stories/District/Layer/country_county.tsx b/stories/District/Layer/country_county.tsx index bb1e89044e..5f6a4636e9 100644 --- a/stories/District/Layer/country_county.tsx +++ b/stories/District/Layer/country_county.tsx @@ -46,7 +46,7 @@ export default class Country extends React.Component { }, popup: { enable: true, - Html: (props) => { + Html: (props: any) => { return `${props.NAME_CHN}`; }, }, diff --git a/stories/District/Layer/world.tsx b/stories/District/Layer/world.tsx index 955ea5e43f..d1a55a9a37 100644 --- a/stories/District/Layer/world.tsx +++ b/stories/District/Layer/world.tsx @@ -48,7 +48,7 @@ export default class Country extends React.Component { }, popup: { enable: false, - Html: (props) => { + Html: (props: any) => { return `${props.NAME_CHN}`; }, }, diff --git a/stories/Draw/Components/DrawLine.tsx b/stories/Draw/Components/DrawLine.tsx index 3cd564279a..dd7873ff1a 100644 --- a/stories/Draw/Components/DrawLine.tsx +++ b/stories/Draw/Components/DrawLine.tsx @@ -21,6 +21,29 @@ export default class Circle extends React.Component { }), }); this.scene = scene; + const linneData = { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + properties: {}, + geometry: { + type: 'LineString', + coordinates: [ + [79.8046875, 52.482780222078226], + [110.74218749999999, 36.87962060502676], + [111.4453125, 19.973348786110602], + [112.8515625, 9.795677582829743], + [95.2734375, -6.664607562172573], + [82.265625, -14.264383087562637], + [74.53125, -25.799891182088306], + [68.203125, -30.145127183376115], + [41.484375, -16.63619187839765], + ], + }, + }, + ], + }; const line = scene.on('loaded', () => { const drawLine = new DrawLine(scene); drawLine.enable(); diff --git a/tsconfig.json b/tsconfig.json index a4e6d4bf49..a03e74a402 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,7 @@ "rootDir": "./", "baseUrl": "./", "paths": { + "@antv/l7-district": ["packages/boundry/src"], "@antv/l7-*": ["packages/*/src"], "@antv/l7": ["packages/l7/src"], "*": ["node_modules", "packages", "typings/*"]