mirror of https://gitee.com/antv-l7/antv-l7
Merge branch 'master' of https://github.com/antvis/L7
This commit is contained in:
commit
bad491ed2f
|
@ -14,7 +14,7 @@
|
||||||
"message": "chore: publish"
|
"message": "chore: publish"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"useWorkspaces": true,
|
"useWorkspaces": true,
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-component",
|
"name": "@antv/l7-component",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -25,8 +25,8 @@
|
||||||
"author": "lzxue",
|
"author": "lzxue",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-core": "^2.4.2",
|
"@antv/l7-core": "^2.4.4",
|
||||||
"@antv/l7-utils": "^2.4.2",
|
"@antv/l7-utils": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"eventemitter3": "^4.0.0",
|
"eventemitter3": "^4.0.0",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-core",
|
"name": "@antv/l7-core",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/async-hook": "^2.1.0",
|
"@antv/async-hook": "^2.1.0",
|
||||||
"@antv/l7-utils": "^2.4.2",
|
"@antv/l7-utils": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@mapbox/tiny-sdf": "^1.1.1",
|
"@mapbox/tiny-sdf": "^1.1.1",
|
||||||
"ajv": "^6.10.2",
|
"ajv": "^6.10.2",
|
||||||
|
|
|
@ -10,7 +10,7 @@ const DragEventMap: { [key: string]: string } = {
|
||||||
panstart: 'dragstart',
|
panstart: 'dragstart',
|
||||||
panmove: 'dragging',
|
panmove: 'dragging',
|
||||||
panend: 'dragend',
|
panend: 'dragend',
|
||||||
pancancel: 'dragcancle',
|
pancancel: 'dragcancel',
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* 由于目前 L7 与地图结合的方案为双 canvas 而非共享 WebGL Context,事件监听注册在地图底图上。
|
* 由于目前 L7 与地图结合的方案为双 canvas 而非共享 WebGL Context,事件监听注册在地图底图上。
|
||||||
|
|
|
@ -8,6 +8,7 @@ export interface ISceneService {
|
||||||
fontFamily: string;
|
fontFamily: string;
|
||||||
loadFont: boolean;
|
loadFont: boolean;
|
||||||
on(type: string, handle: (...args: any[]) => void): void;
|
on(type: string, handle: (...args: any[]) => void): void;
|
||||||
|
once(type: string, handle: (...args: any[]) => void): void;
|
||||||
off(type: string, handle: (...args: any[]) => void): void;
|
off(type: string, handle: (...args: any[]) => void): void;
|
||||||
removeAllListeners(event?: string): this;
|
removeAllListeners(event?: string): this;
|
||||||
init(config: IMapConfig & IRenderConfig): void;
|
init(config: IMapConfig & IRenderConfig): void;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7",
|
"name": "@antv/l7",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "A Large-scale WebGL-powered Geospatial Data Visualization",
|
"description": "A Large-scale WebGL-powered Geospatial Data Visualization",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -25,12 +25,12 @@
|
||||||
"author": "antv",
|
"author": "antv",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-component": "^2.4.2",
|
"@antv/l7-component": "^2.4.4",
|
||||||
"@antv/l7-core": "^2.4.2",
|
"@antv/l7-core": "^2.4.4",
|
||||||
"@antv/l7-layers": "^2.4.2",
|
"@antv/l7-layers": "^2.4.4",
|
||||||
"@antv/l7-maps": "^2.4.2",
|
"@antv/l7-maps": "^2.4.4",
|
||||||
"@antv/l7-scene": "^2.4.2",
|
"@antv/l7-scene": "^2.4.4",
|
||||||
"@antv/l7-utils": "^2.4.2",
|
"@antv/l7-utils": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7"
|
"@babel/runtime": "^7.7.7"
|
||||||
},
|
},
|
||||||
"gitHead": "719d3b75bdfbb7a98767858333b90be92179fed0",
|
"gitHead": "719d3b75bdfbb7a98767858333b90be92179fed0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-layers",
|
"name": "@antv/l7-layers",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "L7's collection of built-in layers",
|
"description": "L7's collection of built-in layers",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -24,10 +24,10 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/async-hook": "^2.1.0",
|
"@antv/async-hook": "^2.1.0",
|
||||||
"@antv/l7-core": "^2.4.2",
|
"@antv/l7-core": "^2.4.4",
|
||||||
"@antv/l7-layers": "^2.4.2",
|
"@antv/l7-layers": "^2.4.4",
|
||||||
"@antv/l7-source": "^2.4.2",
|
"@antv/l7-source": "^2.4.4",
|
||||||
"@antv/l7-utils": "^2.4.2",
|
"@antv/l7-utils": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@mapbox/martini": "^0.2.0",
|
"@mapbox/martini": "^0.2.0",
|
||||||
"@turf/meta": "^6.0.2",
|
"@turf/meta": "^6.0.2",
|
||||||
|
|
|
@ -774,9 +774,16 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
public setSource(source: Source) {
|
public setSource(source: Source) {
|
||||||
|
// 清除旧 sources 事件
|
||||||
|
if (this.layerSource) {
|
||||||
|
this.layerSource.off('update', this.sourceEvent);
|
||||||
|
}
|
||||||
|
|
||||||
this.layerSource = source;
|
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);
|
this.layerSource.updateClusterData(zoom);
|
||||||
}
|
}
|
||||||
// source 可能会复用,会在其它layer被修改
|
// source 可能会复用,会在其它layer被修改
|
||||||
|
|
|
@ -15,8 +15,12 @@ export default class DataSourcePlugin implements ILayerPlugin {
|
||||||
public apply(layer: ILayer) {
|
public apply(layer: ILayer) {
|
||||||
this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);
|
this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);
|
||||||
layer.hooks.init.tap('DataSourcePlugin', () => {
|
layer.hooks.init.tap('DataSourcePlugin', () => {
|
||||||
const { data, options } = layer.sourceOption;
|
const source = layer.getSource();
|
||||||
layer.setSource(new Source(data, options));
|
if (!source) {
|
||||||
|
const { data, options } = layer.sourceOption;
|
||||||
|
layer.setSource(new Source(data, options));
|
||||||
|
}
|
||||||
|
|
||||||
this.updateClusterData(layer);
|
this.updateClusterData(layer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-map",
|
"name": "@antv/l7-map",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "l7 map",
|
"description": "l7 map",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "thinkinggis <lzx199065@gmail.com>",
|
"author": "thinkinggis <lzx199065@gmail.com>",
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/antvis/L7#readme",
|
"homepage": "https://github.com/antvis/L7#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-utils": "^2.4.2",
|
"@antv/l7-utils": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@mapbox/point-geometry": "^0.1.0",
|
"@mapbox/point-geometry": "^0.1.0",
|
||||||
"@mapbox/unitbezier": "^0.0.0",
|
"@mapbox/unitbezier": "^0.0.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-maps",
|
"name": "@antv/l7-maps",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -27,9 +27,9 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@amap/amap-jsapi-loader": "^0.0.3",
|
"@amap/amap-jsapi-loader": "^0.0.3",
|
||||||
"@antv/l7-core": "^2.4.2",
|
"@antv/l7-core": "^2.4.4",
|
||||||
"@antv/l7-map": "^2.4.2",
|
"@antv/l7-map": "^2.4.4",
|
||||||
"@antv/l7-utils": "^2.4.2",
|
"@antv/l7-utils": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@types/amap-js-api": "^1.4.6",
|
"@types/amap-js-api": "^1.4.6",
|
||||||
"@types/mapbox-gl": "^1.11.2",
|
"@types/mapbox-gl": "^1.11.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-renderer",
|
"name": "@antv/l7-renderer",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
"gl": "^4.4.0"
|
"gl": "^4.4.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-core": "^2.4.2",
|
"@antv/l7-core": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-scene",
|
"name": "@antv/l7-scene",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -23,12 +23,12 @@
|
||||||
"author": "xiaoiver",
|
"author": "xiaoiver",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-component": "^2.4.2",
|
"@antv/l7-component": "^2.4.4",
|
||||||
"@antv/l7-core": "^2.4.2",
|
"@antv/l7-core": "^2.4.4",
|
||||||
"@antv/l7-layers": "^2.4.2",
|
"@antv/l7-layers": "^2.4.4",
|
||||||
"@antv/l7-maps": "^2.4.2",
|
"@antv/l7-maps": "^2.4.4",
|
||||||
"@antv/l7-renderer": "^2.4.2",
|
"@antv/l7-renderer": "^2.4.4",
|
||||||
"@antv/l7-utils": "^2.4.2",
|
"@antv/l7-utils": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
"mapbox-gl": "^1.2.1",
|
"mapbox-gl": "^1.2.1",
|
||||||
|
|
|
@ -266,6 +266,12 @@ class Scene
|
||||||
: this.sceneService.on(type, handle);
|
: 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 {
|
public off(type: string, handle: (...args: any[]) => void): void {
|
||||||
SceneEventList.indexOf(type) === -1
|
SceneEventList.indexOf(type) === -1
|
||||||
? this.mapService.off(type, handle)
|
? this.mapService.off(type, handle)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-source",
|
"name": "@antv/l7-source",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
@ -26,8 +26,8 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/async-hook": "^2.1.0",
|
"@antv/async-hook": "^2.1.0",
|
||||||
"@antv/l7-core": "^2.4.2",
|
"@antv/l7-core": "^2.4.4",
|
||||||
"@antv/l7-utils": "^2.4.2",
|
"@antv/l7-utils": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"@mapbox/geojson-rewind": "^0.4.0",
|
"@mapbox/geojson-rewind": "^0.4.0",
|
||||||
"@turf/helpers": "^6.1.4",
|
"@turf/helpers": "^6.1.4",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-three",
|
"name": "@antv/l7-three",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "three for L7 ",
|
"description": "three for L7 ",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"3D",
|
"3D",
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/antvis/L7#readme",
|
"homepage": "https://github.com/antvis/L7#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7": "^2.4.2",
|
"@antv/l7": "^2.4.4",
|
||||||
"@babel/runtime": "^7.7.7",
|
"@babel/runtime": "^7.7.7",
|
||||||
"inversify": "^5.0.1",
|
"inversify": "^5.0.1",
|
||||||
"rollup": "^2.3.3",
|
"rollup": "^2.3.3",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@antv/l7-utils",
|
"name": "@antv/l7-utils",
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"module": "es/index.js",
|
"module": "es/index.js",
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { storiesOf } from '@storybook/react';
|
import { storiesOf } from '@storybook/react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import HolePolygon from './components/hole'
|
import HolePolygon from './components/hole';
|
||||||
import Line from './components/line';
|
import Line from './components/line';
|
||||||
import MultiLine from './components/multiLine';
|
import MultiLine from './components/multiLine';
|
||||||
import MultiPolygon from './components/multiPolygon';
|
import MultiPolygon from './components/multiPolygon';
|
||||||
import UpdatePolygon from './components/updatedata';
|
import UpdatePolygon from './components/ReuseSource';
|
||||||
|
import ReuseSource from './components/ReuseSource';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import notes from './Map.md';
|
import notes from './Map.md';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -13,4 +14,5 @@ storiesOf('数据', module)
|
||||||
.add('updatePolygon', () => <UpdatePolygon />, {})
|
.add('updatePolygon', () => <UpdatePolygon />, {})
|
||||||
.add('MultiLine', () => <MultiLine />, {})
|
.add('MultiLine', () => <MultiLine />, {})
|
||||||
.add('HolePolygon', () => <HolePolygon />, {})
|
.add('HolePolygon', () => <HolePolygon />, {})
|
||||||
.add('折线', () => <Line />, {});
|
.add('折线', () => <Line />, {})
|
||||||
|
.add('复用 Source', () => <ReuseSource />, {});
|
||||||
|
|
|
@ -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,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue