This commit is contained in:
2912401452 2021-07-12 20:09:06 +08:00
commit bad491ed2f
19 changed files with 138 additions and 47 deletions

View File

@ -14,7 +14,7 @@
"message": "chore: publish"
}
},
"version": "2.4.2",
"version": "2.4.4",
"npmClient": "yarn",
"useWorkspaces": true,
"publishConfig": {

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-component",
"version": "2.4.2",
"version": "2.4.4",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -25,8 +25,8 @@
"author": "lzxue",
"license": "ISC",
"dependencies": {
"@antv/l7-core": "^2.4.2",
"@antv/l7-utils": "^2.4.2",
"@antv/l7-core": "^2.4.4",
"@antv/l7-utils": "^2.4.4",
"@babel/runtime": "^7.7.7",
"eventemitter3": "^4.0.0",
"inversify": "^5.0.1",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-core",
"version": "2.4.2",
"version": "2.4.4",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -24,7 +24,7 @@
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.1.0",
"@antv/l7-utils": "^2.4.2",
"@antv/l7-utils": "^2.4.4",
"@babel/runtime": "^7.7.7",
"@mapbox/tiny-sdf": "^1.1.1",
"ajv": "^6.10.2",

View File

@ -10,7 +10,7 @@ const DragEventMap: { [key: string]: string } = {
panstart: 'dragstart',
panmove: 'dragging',
panend: 'dragend',
pancancel: 'dragcancle',
pancancel: 'dragcancel',
};
/**
* L7 canvas WebGL Context

View File

@ -8,6 +8,7 @@ export interface ISceneService {
fontFamily: string;
loadFont: boolean;
on(type: string, handle: (...args: any[]) => void): void;
once(type: string, handle: (...args: any[]) => void): void;
off(type: string, handle: (...args: any[]) => void): void;
removeAllListeners(event?: string): this;
init(config: IMapConfig & IRenderConfig): void;

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7",
"version": "2.4.2",
"version": "2.4.4",
"description": "A Large-scale WebGL-powered Geospatial Data Visualization",
"main": "lib/index.js",
"module": "es/index.js",
@ -25,12 +25,12 @@
"author": "antv",
"license": "MIT",
"dependencies": {
"@antv/l7-component": "^2.4.2",
"@antv/l7-core": "^2.4.2",
"@antv/l7-layers": "^2.4.2",
"@antv/l7-maps": "^2.4.2",
"@antv/l7-scene": "^2.4.2",
"@antv/l7-utils": "^2.4.2",
"@antv/l7-component": "^2.4.4",
"@antv/l7-core": "^2.4.4",
"@antv/l7-layers": "^2.4.4",
"@antv/l7-maps": "^2.4.4",
"@antv/l7-scene": "^2.4.4",
"@antv/l7-utils": "^2.4.4",
"@babel/runtime": "^7.7.7"
},
"gitHead": "719d3b75bdfbb7a98767858333b90be92179fed0",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-layers",
"version": "2.4.2",
"version": "2.4.4",
"description": "L7's collection of built-in layers",
"main": "lib/index.js",
"module": "es/index.js",
@ -24,10 +24,10 @@
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.1.0",
"@antv/l7-core": "^2.4.2",
"@antv/l7-layers": "^2.4.2",
"@antv/l7-source": "^2.4.2",
"@antv/l7-utils": "^2.4.2",
"@antv/l7-core": "^2.4.4",
"@antv/l7-layers": "^2.4.4",
"@antv/l7-source": "^2.4.4",
"@antv/l7-utils": "^2.4.4",
"@babel/runtime": "^7.7.7",
"@mapbox/martini": "^0.2.0",
"@turf/meta": "^6.0.2",

View File

@ -774,9 +774,16 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
}
public setSource(source: Source) {
// 清除旧 sources 事件
if (this.layerSource) {
this.layerSource.off('update', this.sourceEvent);
}
this.layerSource = source;
const zoom = this.mapService.getZoom();
if (this.layerSource.cluster) {
// 已 inited 且启用聚合进行更新聚合数据
if (this.inited && this.layerSource.cluster) {
const zoom = this.mapService.getZoom();
this.layerSource.updateClusterData(zoom);
}
// source 可能会复用会在其它layer被修改

View File

@ -15,8 +15,12 @@ export default class DataSourcePlugin implements ILayerPlugin {
public apply(layer: ILayer) {
this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);
layer.hooks.init.tap('DataSourcePlugin', () => {
const { data, options } = layer.sourceOption;
layer.setSource(new Source(data, options));
const source = layer.getSource();
if (!source) {
const { data, options } = layer.sourceOption;
layer.setSource(new Source(data, options));
}
this.updateClusterData(layer);
});

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-map",
"version": "2.4.2",
"version": "2.4.4",
"description": "l7 map",
"keywords": [],
"author": "thinkinggis <lzx199065@gmail.com>",
@ -37,7 +37,7 @@
},
"homepage": "https://github.com/antvis/L7#readme",
"dependencies": {
"@antv/l7-utils": "^2.4.2",
"@antv/l7-utils": "^2.4.4",
"@babel/runtime": "^7.7.7",
"@mapbox/point-geometry": "^0.1.0",
"@mapbox/unitbezier": "^0.0.0",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-maps",
"version": "2.4.2",
"version": "2.4.4",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -27,9 +27,9 @@
"license": "ISC",
"dependencies": {
"@amap/amap-jsapi-loader": "^0.0.3",
"@antv/l7-core": "^2.4.2",
"@antv/l7-map": "^2.4.2",
"@antv/l7-utils": "^2.4.2",
"@antv/l7-core": "^2.4.4",
"@antv/l7-map": "^2.4.4",
"@antv/l7-utils": "^2.4.4",
"@babel/runtime": "^7.7.7",
"@types/amap-js-api": "^1.4.6",
"@types/mapbox-gl": "^1.11.2",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-renderer",
"version": "2.4.2",
"version": "2.4.4",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -26,7 +26,7 @@
"gl": "^4.4.0"
},
"dependencies": {
"@antv/l7-core": "^2.4.2",
"@antv/l7-core": "^2.4.4",
"@babel/runtime": "^7.7.7",
"inversify": "^5.0.1",
"lodash": "^4.17.15",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-scene",
"version": "2.4.2",
"version": "2.4.4",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -23,12 +23,12 @@
"author": "xiaoiver",
"license": "ISC",
"dependencies": {
"@antv/l7-component": "^2.4.2",
"@antv/l7-core": "^2.4.2",
"@antv/l7-layers": "^2.4.2",
"@antv/l7-maps": "^2.4.2",
"@antv/l7-renderer": "^2.4.2",
"@antv/l7-utils": "^2.4.2",
"@antv/l7-component": "^2.4.4",
"@antv/l7-core": "^2.4.4",
"@antv/l7-layers": "^2.4.4",
"@antv/l7-maps": "^2.4.4",
"@antv/l7-renderer": "^2.4.4",
"@antv/l7-utils": "^2.4.4",
"@babel/runtime": "^7.7.7",
"inversify": "^5.0.1",
"mapbox-gl": "^1.2.1",

View File

@ -266,6 +266,12 @@ class Scene
: this.sceneService.on(type, handle);
}
public once(type: string, handle: (...args: any[]) => void): void {
SceneEventList.indexOf(type) === -1
? this.mapService.once(type, handle)
: this.sceneService.once(type, handle);
}
public off(type: string, handle: (...args: any[]) => void): void {
SceneEventList.indexOf(type) === -1
? this.mapService.off(type, handle)

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-source",
"version": "2.4.2",
"version": "2.4.4",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",
@ -26,8 +26,8 @@
"license": "ISC",
"dependencies": {
"@antv/async-hook": "^2.1.0",
"@antv/l7-core": "^2.4.2",
"@antv/l7-utils": "^2.4.2",
"@antv/l7-core": "^2.4.4",
"@antv/l7-utils": "^2.4.4",
"@babel/runtime": "^7.7.7",
"@mapbox/geojson-rewind": "^0.4.0",
"@turf/helpers": "^6.1.4",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-three",
"version": "2.4.2",
"version": "2.4.4",
"description": "three for L7 ",
"keywords": [
"3D",
@ -44,7 +44,7 @@
},
"homepage": "https://github.com/antvis/L7#readme",
"dependencies": {
"@antv/l7": "^2.4.2",
"@antv/l7": "^2.4.4",
"@babel/runtime": "^7.7.7",
"inversify": "^5.0.1",
"rollup": "^2.3.3",

View File

@ -1,6 +1,6 @@
{
"name": "@antv/l7-utils",
"version": "2.4.2",
"version": "2.4.4",
"description": "",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -1,10 +1,11 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import HolePolygon from './components/hole'
import HolePolygon from './components/hole';
import Line from './components/line';
import MultiLine from './components/multiLine';
import MultiPolygon from './components/multiPolygon';
import UpdatePolygon from './components/updatedata';
import UpdatePolygon from './components/ReuseSource';
import ReuseSource from './components/ReuseSource';
// @ts-ignore
import notes from './Map.md';
// @ts-ignore
@ -13,4 +14,5 @@ storiesOf('数据', module)
.add('updatePolygon', () => <UpdatePolygon />, {})
.add('MultiLine', () => <MultiLine />, {})
.add('HolePolygon', () => <HolePolygon />, {})
.add('折线', () => <Line />, {});
.add('折线', () => <Line />, {})
.add('复用 Source', () => <ReuseSource />, {});

View File

@ -0,0 +1,71 @@
import { LineLayer, PolygonLayer, Scene } from '@antv/l7';
import { GaodeMap } from '@antv/l7-maps';
import Source from '@antv/l7-source';
import * as React from 'react';
export default class ReuseSource extends React.Component {
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new GaodeMap({
style: 'dark',
center: [104.288144, 31.239692],
zoom: 4.4,
}),
});
scene.on('loaded', async () => {
const response = await fetch(
'https://gw.alipayobjects.com/os/rmsportal/JToMOWvicvJOISZFCkEI.json',
);
const data = await response.json();
const source = new Source(data);
const polygonLayer = new PolygonLayer({})
.shape('fill')
.color('rgba(255,255,255,0.2)')
.select({
color: 'red',
})
.style({
opacity: 1,
});
polygonLayer.setSource(source);
polygonLayer.on('click', (e) => {
source.setData({
type: 'FeatureCollection',
features: [e.feature],
});
});
const lineLayer = new LineLayer({}).shape('line').color('#0ffbc4');
lineLayer.setSource(source);
scene.addLayer(polygonLayer);
scene.addLayer(lineLayer);
this.scene = scene;
});
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}