mirror of https://gitee.com/antv-l7/antv-l7
commit
f676f9beca
|
@ -12,7 +12,7 @@ L7 focuses on geographic data expressiveness,interaction and design of geograp
|
||||||
|
|
||||||
## 🌄 l7 visualization demos
|
## 🌄 l7 visualization demos
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 🌟 Highlight features of L7 2.0
|
## 🌟 Highlight features of L7 2.0
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ L7 是由蚂蚁金服 AntV 数据可视化团队推出的基于 WebGL 的开源
|
||||||
|
|
||||||
L7 能够满足常见的地图图表,BI 系统的可视化分析、以及 GIS,交通,电力,国土,农业,城市等领域的空间信息管理,分析等应用系统开发需求。
|
L7 能够满足常见的地图图表,BI 系统的可视化分析、以及 GIS,交通,电力,国土,农业,城市等领域的空间信息管理,分析等应用系统开发需求。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 🌟 核心特性
|
## 🌟 核心特性
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,24 @@ scene.removeLayer(layer);
|
||||||
|
|
||||||
移除事件监听<br />`eventName` {string} 事件名<br />`hander` {function } 事件回调函数
|
移除事件监听<br />`eventName` {string} 事件名<br />`hander` {function } 事件回调函数
|
||||||
|
|
||||||
|
### 场景事件
|
||||||
|
|
||||||
|
#### loaded
|
||||||
|
|
||||||
|
scene 初始化完成事件,scene 初始化完成添加 Layer
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
scene.on('loaded', () => {});
|
||||||
|
```
|
||||||
|
|
||||||
|
#### resize
|
||||||
|
|
||||||
|
地图容器变化事件
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
scene.on('resize', () => {}); // 地图容器大小改变事件
|
||||||
|
```
|
||||||
|
|
||||||
### 地图事件
|
### 地图事件
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -350,9 +368,3 @@ scene.on('dragstart', (ev) => {}); //开始拖拽地图时触发
|
||||||
scene.on('dragging', (ev) => {}); // 拖拽地图过程中触发
|
scene.on('dragging', (ev) => {}); // 拖拽地图过程中触发
|
||||||
scene.on('dragend', (ev) => {}); //停止拖拽地图时触发。如地图有拖拽缓动效果,则在拽停止,缓动开始前触发
|
scene.on('dragend', (ev) => {}); //停止拖拽地图时触发。如地图有拖拽缓动效果,则在拽停止,缓动开始前触发
|
||||||
```
|
```
|
||||||
|
|
||||||
### 其它事件
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
scene.on('resize', () => {}); // 地图容器大小改变事件
|
|
||||||
```
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ const scene = new Scene({
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
Promise.all([
|
Promise.all([
|
||||||
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/world.geo.json').then(d => d.json()),
|
fetch('https://gw.alipayobjects.com/os/basement_prod/dbd008f1-9189-461c-88aa-569357ffc07d.json').then(d => d.json()),
|
||||||
fetch('https://gw.alipayobjects.com/os/basement_prod/4472780b-fea1-4fc2-9e4b-3ca716933dc7.json').then(d => d.text()),
|
fetch('https://gw.alipayobjects.com/os/basement_prod/4472780b-fea1-4fc2-9e4b-3ca716933dc7.json').then(d => d.text()),
|
||||||
fetch('https://gw.alipayobjects.com/os/basement_prod/a5ac7bce-181b-40d1-8a16-271356264ad8.json').then(d => d.text())
|
fetch('https://gw.alipayobjects.com/os/basement_prod/a5ac7bce-181b-40d1-8a16-271356264ad8.json').then(d => d.text())
|
||||||
]).then(function onLoad([ world, dot, flyline ]) {
|
]).then(function onLoad([ world, dot, flyline ]) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ const scene = new Scene({
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
Promise.all([
|
Promise.all([
|
||||||
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/world.geo.json').then(d => d.json()),
|
fetch('https://gw.alipayobjects.com/os/basement_prod/dbd008f1-9189-461c-88aa-569357ffc07d.json').then(d => d.json()),
|
||||||
fetch('https://gw.alipayobjects.com/os/basement_prod/4472780b-fea1-4fc2-9e4b-3ca716933dc7.json').then(d => d.text()),
|
fetch('https://gw.alipayobjects.com/os/basement_prod/4472780b-fea1-4fc2-9e4b-3ca716933dc7.json').then(d => d.text()),
|
||||||
fetch('https://gw.alipayobjects.com/os/basement_prod/a5ac7bce-181b-40d1-8a16-271356264ad8.json').then(d => d.text())
|
fetch('https://gw.alipayobjects.com/os/basement_prod/a5ac7bce-181b-40d1-8a16-271356264ad8.json').then(d => d.text())
|
||||||
]).then(function onLoad([ world, dot, flyline ]) {
|
]).then(function onLoad([ world, dot, flyline ]) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ export interface IMarkerService {
|
||||||
addMarker(Marker: IMarker): void;
|
addMarker(Marker: IMarker): void;
|
||||||
addMarkers(): void;
|
addMarkers(): void;
|
||||||
removeMarker(Marker: IMarker): void;
|
removeMarker(Marker: IMarker): void;
|
||||||
|
removeAllMarkers(): void;
|
||||||
init(scene: Container): void;
|
init(scene: Container): void;
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ export default class MarkerService implements IMarkerService {
|
||||||
this.unAddMarkers.push(marker);
|
this.unAddMarkers.push(marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addMarkers(): void {
|
public addMarkers(): void {
|
||||||
this.unAddMarkers.forEach((marker: IMarker) => {
|
this.unAddMarkers.forEach((marker: IMarker) => {
|
||||||
marker.addTo(this.scene);
|
marker.addTo(this.scene);
|
||||||
|
@ -25,9 +26,15 @@ export default class MarkerService implements IMarkerService {
|
||||||
});
|
});
|
||||||
this.unAddMarkers = [];
|
this.unAddMarkers = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeMarker(marker: IMarker): void {
|
public removeMarker(marker: IMarker): void {
|
||||||
marker.remove();
|
marker.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public removeAllMarkers(): void {
|
||||||
|
this.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
public init(scene: Container): void {
|
public init(scene: Container): void {
|
||||||
// this.container = cfg.container;
|
// this.container = cfg.container;
|
||||||
this.scene = scene;
|
this.scene = scene;
|
||||||
|
|
|
@ -264,6 +264,7 @@ export interface ILayerService {
|
||||||
getLayers(): ILayer[];
|
getLayers(): ILayer[];
|
||||||
getLayer(name: string): ILayer | undefined;
|
getLayer(name: string): ILayer | undefined;
|
||||||
remove(layer: ILayer): void;
|
remove(layer: ILayer): void;
|
||||||
|
removeAllLayers(): void;
|
||||||
updateRenderOrder(): void;
|
updateRenderOrder(): void;
|
||||||
renderLayers(): void;
|
renderLayers(): void;
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { TYPES } from '../../types';
|
||||||
import Clock from '../../utils/clock';
|
import Clock from '../../utils/clock';
|
||||||
import { IGlobalConfigService } from '../config/IConfigService';
|
import { IGlobalConfigService } from '../config/IConfigService';
|
||||||
import { IRendererService } from '../renderer/IRendererService';
|
import { IRendererService } from '../renderer/IRendererService';
|
||||||
import { ILayerService } from './ILayerService';
|
import { ILayerModel, ILayerService } from './ILayerService';
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class LayerService implements ILayerService {
|
export default class LayerService implements ILayerService {
|
||||||
|
@ -52,6 +52,10 @@ export default class LayerService implements ILayerService {
|
||||||
this.renderLayers();
|
this.renderLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public removeAllLayers() {
|
||||||
|
this.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
public renderLayers() {
|
public renderLayers() {
|
||||||
// TODO:脏检查,只渲染发生改变的 Layer
|
// TODO:脏检查,只渲染发生改变的 Layer
|
||||||
//
|
//
|
||||||
|
@ -77,6 +81,7 @@ export default class LayerService implements ILayerService {
|
||||||
public destroy() {
|
public destroy() {
|
||||||
this.layers.forEach((layer) => layer.destroy());
|
this.layers.forEach((layer) => layer.destroy());
|
||||||
this.layers = [];
|
this.layers = [];
|
||||||
|
this.renderLayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public startAnimate() {
|
public startAnimate() {
|
||||||
|
|
|
@ -11,6 +11,7 @@ export interface IPoint {
|
||||||
y: number;
|
y: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type MapStyle = string | { [key: string]: any };
|
||||||
export interface IMapWrapper {
|
export interface IMapWrapper {
|
||||||
setContainer(container: Container, id: string): void;
|
setContainer(container: Container, id: string): void;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +109,7 @@ export interface IMapConfig<RawMap = {}> {
|
||||||
/**
|
/**
|
||||||
* 底图样式
|
* 底图样式
|
||||||
*/
|
*/
|
||||||
style?: string;
|
style?: MapStyle;
|
||||||
/**
|
/**
|
||||||
* 最小缩放等级
|
* 最小缩放等级
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
IPoint,
|
IPoint,
|
||||||
IViewport,
|
IViewport,
|
||||||
MapServiceEvent,
|
MapServiceEvent,
|
||||||
|
MapStyle,
|
||||||
TYPES,
|
TYPES,
|
||||||
} from '@antv/l7-core';
|
} from '@antv/l7-core';
|
||||||
import { DOM } from '@antv/l7-utils';
|
import { DOM } from '@antv/l7-utils';
|
||||||
|
@ -249,7 +250,7 @@ export default class AMapService
|
||||||
);
|
);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.map = new AMap.Map(this.$mapContainer, {
|
this.map = new AMap.Map(this.$mapContainer, {
|
||||||
mapStyle: this.getMapStyle(style),
|
mapStyle: this.getMapStyle(style as string),
|
||||||
zooms: [minZoom, maxZoom],
|
zooms: [minZoom, maxZoom],
|
||||||
viewMode: '3D',
|
viewMode: '3D',
|
||||||
...rest,
|
...rest,
|
||||||
|
@ -361,7 +362,7 @@ export default class AMapService
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private getMapStyle(name: string) {
|
private getMapStyle(name: string): string {
|
||||||
return MapTheme[name] ? MapTheme[name] : name;
|
return MapTheme[name] ? MapTheme[name] : name;
|
||||||
}
|
}
|
||||||
private creatAmapContainer(id: string | HTMLDivElement) {
|
private creatAmapContainer(id: string | HTMLDivElement) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import {
|
||||||
IPoint,
|
IPoint,
|
||||||
IViewport,
|
IViewport,
|
||||||
MapServiceEvent,
|
MapServiceEvent,
|
||||||
|
MapStyle,
|
||||||
TYPES,
|
TYPES,
|
||||||
} from '@antv/l7-core';
|
} from '@antv/l7-core';
|
||||||
import { DOM } from '@antv/l7-utils';
|
import { DOM } from '@antv/l7-utils';
|
||||||
|
@ -318,7 +319,10 @@ export default class MapboxService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getMapStyle(name: string) {
|
private getMapStyle(name: MapStyle) {
|
||||||
|
if (typeof name !== 'string') {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
return MapTheme[name] ? MapTheme[name] : name;
|
return MapTheme[name] ? MapTheme[name] : name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ class Scene
|
||||||
return this.mapService.map;
|
return this.mapService.map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// layer 管理
|
||||||
public addLayer(layer: ILayer): void {
|
public addLayer(layer: ILayer): void {
|
||||||
// 为当前图层创建一个容器
|
// 为当前图层创建一个容器
|
||||||
// TODO: 初始化的时候设置 容器
|
// TODO: 初始化的时候设置 容器
|
||||||
|
@ -127,6 +128,10 @@ class Scene
|
||||||
this.layerService.remove(layer);
|
this.layerService.remove(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public removeAllLayer(): void {
|
||||||
|
this.layerService.removeAllLayers();
|
||||||
|
}
|
||||||
|
|
||||||
public render(): void {
|
public render(): void {
|
||||||
this.sceneService.render();
|
this.sceneService.render();
|
||||||
}
|
}
|
||||||
|
@ -158,9 +163,14 @@ class Scene
|
||||||
this.markerService.addMarker(marker);
|
this.markerService.addMarker(marker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public removeAllMakers() {
|
||||||
|
this.markerService.removeAllMarkers();
|
||||||
|
}
|
||||||
|
|
||||||
public addPopup(popup: IPopup) {
|
public addPopup(popup: IPopup) {
|
||||||
this.popupService.addPopup(popup);
|
this.popupService.addPopup(popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public on(type: string, handle: (...args: any[]) => void): void {
|
public on(type: string, handle: (...args: any[]) => void): void {
|
||||||
SceneEventList.indexOf(type) === -1
|
SceneEventList.indexOf(type) === -1
|
||||||
? this.mapService.on(type, handle)
|
? this.mapService.on(type, handle)
|
||||||
|
|
|
@ -53,14 +53,16 @@ export default class DataUpdate extends React.Component {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
});
|
});
|
||||||
scene.addLayer(layer);
|
scene.addLayer(layer);
|
||||||
function animateMarker(timestamp: number) {
|
layer.setData(pointOnCircle(1000));
|
||||||
layer.setData(pointOnCircle(timestamp / 1000));
|
scene.render();
|
||||||
scene.render();
|
// function animateMarker(timestamp: number) {
|
||||||
requestAnimationFrame(animateMarker);
|
// layer.setData(pointOnCircle(timestamp / 1000));
|
||||||
}
|
// scene.render();
|
||||||
layer.on('inited', () => {
|
// requestAnimationFrame(animateMarker);
|
||||||
animateMarker(0);
|
// }
|
||||||
});
|
// layer.on('inited', () => {
|
||||||
|
// animateMarker(0);
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
|
Loading…
Reference in New Issue