From ad60db08558c2bf808448fa67b67856e162c4afe Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Fri, 20 Mar 2020 15:02:46 +0800 Subject: [PATCH 1/2] docs: scene add getContainer method --- docs/api/scene.en.md | 8 ++++++++ docs/api/scene.zh.md | 8 ++++++++ examples/react/covid/demo/meta.json | 2 +- package.json | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/api/scene.en.md b/docs/api/scene.en.md index 1f06067347..d51f54401c 100644 --- a/docs/api/scene.en.md +++ b/docs/api/scene.en.md @@ -323,6 +323,14 @@ scene.setPitch(pitch); scene.fitBounds([112, 32, 114, 35]); ``` +### getContainer + +获取地图容器 return htmlElement + +```javascript +scene.getContainer(); +``` + ### removeLayer 移除 layer diff --git a/docs/api/scene.zh.md b/docs/api/scene.zh.md index 4f2b155313..5b40017b0c 100644 --- a/docs/api/scene.zh.md +++ b/docs/api/scene.zh.md @@ -208,6 +208,14 @@ scene.getPitch(); return {number} pitch +### getContainer + +获取地图容器 return htmlElement + +```javascript +scene.getContainer(); +``` + ### setMapStyle 参数:`style` {string} 地图样式 具体样式格式和各底图设置方法一致 diff --git a/examples/react/covid/demo/meta.json b/examples/react/covid/demo/meta.json index c0025388c6..d709dc6a38 100644 --- a/examples/react/covid/demo/meta.json +++ b/examples/react/covid/demo/meta.json @@ -7,7 +7,7 @@ { "filename": "covid_grid.tsx", "title": "世界地图网格背景", - "screenshot": "https://gw.alipayobjects.com/mdn/rms_855bab/afts/img/A*YYNtRZpxH_4AAAAAAAAAAABkARQnAQ" + "screenshot": "https://gw.alipayobjects.com/mdn/rms_23a451/afts/img/A*CSUXTIYXXFwAAAAAAAAAAABkARQnAQ" }, { "filename": "covid_animate.tsx", diff --git a/package.json b/package.json index 224468f57b..d3d82d4224 100644 --- a/package.json +++ b/package.json @@ -175,7 +175,7 @@ } }, "resolutions": { - "../core-js": "3", + "core-js": "3", "d3-array": "1" }, "tnpm": { From 8878983bff19e890da377de5c4e70bfc74a5ab37 Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Fri, 20 Mar 2020 19:02:41 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20observerable=E6=89=93=E5=8C=85?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- babel.config.js | 2 +- package.json | 3 +- packages/draw/package.json | 4 + packages/draw/src/modes/draw_circle.ts | 22 + packages/draw/src/modes/draw_feature.ts | 34 +- packages/l7/demo/circle.html | 2 +- packages/l7/demo/polygon.html | 18 +- packages/l7/src/index.ts | 1 + yarn.lock | 25083 ++++++++++++++++++++++ 9 files changed, 25143 insertions(+), 26 deletions(-) create mode 100644 packages/draw/src/modes/draw_circle.ts create mode 100644 yarn.lock diff --git a/babel.config.js b/babel.config.js index cd575482f3..56516caee2 100644 --- a/babel.config.js +++ b/babel.config.js @@ -44,7 +44,7 @@ module.exports = api => { { // https://babeljs.io/docs/en/babel-preset-env#usebuiltins // useBuiltIns: 'usage', - ...isCDNBundle ? { corejs: '2.0.0' } : {}, + ...isCDNBundle ? { corejs: '3.0.0' } : {}, useBuiltIns: isCDNBundle ? 'usage' : false, // set `modules: false` when building CDN bundle, let rollup do commonjs works // @see https://github.com/rollup/rollup-plugin-babel#modules diff --git a/package.json b/package.json index d3d82d4224..bf9677cad5 100644 --- a/package.json +++ b/package.json @@ -149,7 +149,7 @@ "coveralls": "jest --coverage && cat ./tests/coverage/lcov.info | coveralls", "tsc": "tsc", "watch": "yarn clean && lerna exec --parallel -- cross-env BABEL_ENV=cjs NODE_ENV=production babel --watch src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments", - "bundle": "cross-env BABEL_ENV=bundle node_modules/.bin/rollup -c ./build/rollup.config.js --environment BUILD:production,MINIFY:true", + "bundle": "cross-env BABEL_ENV=bundle NODE_ENV=production node_modules/.bin/rollup -c ./build/rollup.config.js --environment BUILD:production,MINIFY:true", "bundle-dev": "cross-env BABEL_ENV=bundle node_modules/.bin/rollup -c ./build/rollup.config.js --environment 'BUILD:production,MINIFY:false'", "bundle:watch": "cross-env BABEL_ENV=bundle node_modules/.bin/rollup -c ./build/rollup.config.js --watch", "glsl-minify": "node_modules/.bin/glsl-minifier -i ./build/example.frag -o ./build/example.min.frag", @@ -175,7 +175,6 @@ } }, "resolutions": { - "core-js": "3", "d3-array": "1" }, "tnpm": { diff --git a/packages/draw/package.json b/packages/draw/package.json index 55fea98718..be22b3b995 100644 --- a/packages/draw/package.json +++ b/packages/draw/package.json @@ -31,6 +31,10 @@ "lint:ts": "run-p -c lint:ts-*", "test": "jest" }, + "dependencies": { + "@antv/l7": "^2.1.3", + "@babel/runtime": "^7.7.7" + }, "bugs": { "url": "https://github.com/antvis/L7/issues" }, diff --git a/packages/draw/src/modes/draw_circle.ts b/packages/draw/src/modes/draw_circle.ts new file mode 100644 index 0000000000..8b219bafa7 --- /dev/null +++ b/packages/draw/src/modes/draw_circle.ts @@ -0,0 +1,22 @@ +import { ILayer } from '@antv/l7'; +import DrawFeature from './draw_feature'; + +export default class DrawCircle extends DrawFeature { + private center: [number, number]; + private drawCircleLayer: ILayer; + protected onDragStart() { + // @ts-ignore + this.scene.map.dragdrag.disable(); + } + protected onDragging() { + return; + } + + protected onDragEnd() { + return; + } + + protected onClick() { + return; + } +} diff --git a/packages/draw/src/modes/draw_feature.ts b/packages/draw/src/modes/draw_feature.ts index 0d7400c1c6..0ebf0d4925 100644 --- a/packages/draw/src/modes/draw_feature.ts +++ b/packages/draw/src/modes/draw_feature.ts @@ -1,3 +1,4 @@ +import { Scene } from '@antv/l7'; import { Feature, FeatureCollection } from '@turf/helpers'; import DrawSource from '../source'; @@ -5,26 +6,35 @@ export interface IDrawOption { data: FeatureCollection; } +export type DrawStatus = 'Drawing' | 'Selected' | 'Edit' | 'Finish'; + export default abstract class DrawFeature { private source: DrawSource; - constructor(options: IDrawOption) { + private scene: Scene; + constructor(scene: Scene, options: IDrawOption) { const { data } = options; + this.scene = scene; this.source = new DrawSource(data); } - - protected onDragStart() { - throw new Error('not imp'); + public enable() { + this.scene.on('dragstart', this.onDragStart); + this.scene.on('drag', this.onDragging); + this.scene.on('dragend', this.onDragEnd); + this.scene.on('click', this.onClick); } - protected onDragging() { - throw new Error('not imp'); + public disable() { + this.scene.off('dragstart', this.onDragStart); + this.scene.off('drag', this.onDragging); + this.scene.off('dragend', this.onDragEnd); + this.scene.off('click', this.onClick); } - protected onDragEnd() { - throw new Error('not imp'); - } + protected abstract onDragStart(): any; - protected onClick() { - throw new Error('not imp'); - } + protected abstract onDragging(): any; + + protected abstract onDragEnd(): any; + + protected abstract onClick(): any; } diff --git a/packages/l7/demo/circle.html b/packages/l7/demo/circle.html index ec957776a9..26cbfd88db 100644 --- a/packages/l7/demo/circle.html +++ b/packages/l7/demo/circle.html @@ -27,7 +27,7 @@ - + - - +