Merge pull request #219 from antvis/fix_react

Fix react
This commit is contained in:
@thinkinggis 2020-02-21 09:15:33 +08:00 committed by GitHub
commit aec7f9dd8a
21 changed files with 69 additions and 52 deletions

View File

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

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7-component", "name": "@antv/l7-component",
"version": "2.0.23", "version": "2.0.24",
"description": "", "description": "",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -24,8 +24,8 @@
"author": "lzxue", "author": "lzxue",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@antv/l7-core": "^2.0.23", "@antv/l7-core": "^2.0.24",
"@antv/l7-utils": "^2.0.23", "@antv/l7-utils": "^2.0.24",
"@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",

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7-core", "name": "@antv/l7-core",
"version": "2.0.23", "version": "2.0.24",
"description": "", "description": "",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -22,7 +22,7 @@
"author": "xiaoiver", "author": "xiaoiver",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@antv/l7-utils": "^2.0.23", "@antv/l7-utils": "^2.0.24",
"@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",

View File

@ -52,6 +52,8 @@ export interface IMapService<RawMap = {}> {
panBy(pixel: Point): void; panBy(pixel: Point): void;
fitBounds(bound: Bounds): void; fitBounds(bound: Bounds): void;
setZoomAndCenter(zoom: number, center: Point): void; setZoomAndCenter(zoom: number, center: Point): void;
setCenter(center: [number, number]): void;
setPitch(pitch: number): void;
setZoom(zoom: number): void; setZoom(zoom: number): void;
setMapStyle(style: string): void; setMapStyle(style: string): void;

View File

@ -234,8 +234,7 @@ export default class Scene extends EventEmitter implements ISceneService {
public exportPng(): string { public exportPng(): string {
const renderCanvas = this.$container?.getElementsByTagName('canvas')[0]; const renderCanvas = this.$container?.getElementsByTagName('canvas')[0];
// this.render(); this.render();
DOM.printCanvas(renderCanvas as HTMLCanvasElement);
const layersPng = renderCanvas?.toDataURL('image/png') as string; const layersPng = renderCanvas?.toDataURL('image/png') as string;
return layersPng; return layersPng;
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7", "name": "@antv/l7",
"version": "2.0.23", "version": "2.0.24",
"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",
@ -24,11 +24,11 @@
"author": "antv", "author": "antv",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@antv/l7-component": "^2.0.23", "@antv/l7-component": "^2.0.24",
"@antv/l7-core": "^2.0.23", "@antv/l7-core": "^2.0.24",
"@antv/l7-layers": "^2.0.23", "@antv/l7-layers": "^2.0.24",
"@antv/l7-maps": "^2.0.23", "@antv/l7-maps": "^2.0.24",
"@antv/l7-scene": "^2.0.23", "@antv/l7-scene": "^2.0.24",
"@babel/runtime": "^7.7.7" "@babel/runtime": "^7.7.7"
}, },
"gitHead": "f2bd3c6473df79d815467b1677c6f985cf68800e", "gitHead": "f2bd3c6473df79d815467b1677c6f985cf68800e",

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7-layers", "name": "@antv/l7-layers",
"version": "2.0.23", "version": "2.0.24",
"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",
@ -22,9 +22,9 @@
"author": "xiaoiver", "author": "xiaoiver",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@antv/l7-core": "^2.0.23", "@antv/l7-core": "^2.0.24",
"@antv/l7-source": "^2.0.23", "@antv/l7-source": "^2.0.24",
"@antv/l7-utils": "^2.0.23", "@antv/l7-utils": "^2.0.24",
"@babel/runtime": "^7.7.7", "@babel/runtime": "^7.7.7",
"@mapbox/martini": "^0.1.0", "@mapbox/martini": "^0.1.0",
"@turf/meta": "^6.0.2", "@turf/meta": "^6.0.2",

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7-maps", "name": "@antv/l7-maps",
"version": "2.0.23", "version": "2.0.24",
"description": "", "description": "",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -23,8 +23,8 @@
"author": "xiaoiver", "author": "xiaoiver",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@antv/l7-core": "^2.0.23", "@antv/l7-core": "^2.0.24",
"@antv/l7-utils": "^2.0.23", "@antv/l7-utils": "^2.0.24",
"@babel/runtime": "^7.7.7", "@babel/runtime": "^7.7.7",
"gl-matrix": "^3.1.0", "gl-matrix": "^3.1.0",
"inversify": "^5.0.1", "inversify": "^5.0.1",

View File

@ -22,6 +22,8 @@ import { IAMapEvent, IAMapInstance } from '../../typings/index';
import { MapTheme } from './theme'; import { MapTheme } from './theme';
import Viewport from './Viewport'; import Viewport from './Viewport';
let mapdivCount = 0; let mapdivCount = 0;
// @ts-ignore
window.forceWebGL = true;
const AMAP_API_KEY: string = '15cd8a57710d40c9b7c0e3cc120f1200'; const AMAP_API_KEY: string = '15cd8a57710d40c9b7c0e3cc120f1200';
const AMAP_VERSION: string = '1.4.15'; const AMAP_VERSION: string = '1.4.15';
@ -129,7 +131,9 @@ export default class AMapService
lat: center.getLat(), lat: center.getLat(),
}; };
} }
public setCenter(lnglat: [number, number]): void {
this.map.setCenter(lnglat);
}
public getPitch(): number { public getPitch(): number {
return this.map.getPitch(); return this.map.getPitch();
} }
@ -165,10 +169,14 @@ export default class AMapService
const zooms = this.map.get('zooms') as [number, number]; const zooms = this.map.get('zooms') as [number, number];
return zooms[1] - 1; return zooms[1] - 1;
} }
public setRotation(rotation: number): void { public setRotation(rotation: number): void {
return this.map.setRotation(rotation); return this.map.setRotation(rotation);
} }
public setPitch(pitch: number) {
return this.map.setPitch(pitch);
}
public zoomIn(): void { public zoomIn(): void {
this.map.zoomIn(); this.map.zoomIn();
} }

View File

@ -107,6 +107,10 @@ export default class MapboxService
return this.map.getCenter(); return this.map.getCenter();
} }
public setCenter(lnglat: [number, number]): void {
this.map.setCenter(lnglat);
}
public getPitch(): number { public getPitch(): number {
return this.map.getPitch(); return this.map.getPitch();
} }
@ -135,6 +139,10 @@ export default class MapboxService
this.map.zoomIn(); this.map.zoomIn();
} }
public setPitch(pitch: number) {
return this.map.setPitch(pitch);
}
public zoomOut(): void { public zoomOut(): void {
this.map.zoomOut(); this.map.zoomOut();
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7-react", "name": "@antv/l7-react",
"version": "2.0.23", "version": "2.0.24",
"description": "", "description": "",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -24,8 +24,8 @@
"author": "lzxue", "author": "lzxue",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@antv/l7": "^2.0.23", "@antv/l7": "^2.0.24",
"@antv/l7-maps": "^2.0.23", "@antv/l7-maps": "^2.0.24",
"@babel/runtime": "^7.7.7", "@babel/runtime": "^7.7.7",
"load-styles": "^2.0.0", "load-styles": "^2.0.0",
"react": "^16.8.6", "react": "^16.8.6",

View File

@ -55,6 +55,7 @@ export default function BaseLayer(type: string, props: ILayerProps) {
}; };
}, []); }, []);
useEffect(() => { useEffect(() => {
// 重绘layer
if (layer) { if (layer) {
mapScene.render(); mapScene.render();
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7-renderer", "name": "@antv/l7-renderer",
"version": "2.0.23", "version": "2.0.24",
"description": "", "description": "",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -25,7 +25,7 @@
"gl": "^4.4.0" "gl": "^4.4.0"
}, },
"dependencies": { "dependencies": {
"@antv/l7-core": "^2.0.23", "@antv/l7-core": "^2.0.24",
"@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",

View File

@ -48,18 +48,21 @@ export default class ReglRendererService implements IRendererService {
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1 // @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
antialias: true, antialias: true,
premultipliedAlpha: true, premultipliedAlpha: true,
preserveDrawingBuffer: false,
}, },
// TODO: use extensions // TODO: use extensions
extensions: [ extensions: [
'OES_element_index_uint', 'OES_element_index_uint',
'EXT_blend_minmax', 'EXT_blend_minmax',
'OES_standard_derivatives', // wireframe 'OES_standard_derivatives', // wireframe
// 'OES_texture_float', // shadow map 兼容性问题
'WEBGL_depth_texture', 'WEBGL_depth_texture',
'angle_instanced_arrays', 'angle_instanced_arrays', // VSM shadow map
'EXT_texture_filter_anisotropic', // VSM shadow map ],
optionalExtensions: [
'oes_texture_float_linear',
'OES_texture_float',
'EXT_texture_filter_anisotropic',
], ],
optionalExtensions: ['oes_texture_float_linear', 'OES_texture_float'],
profile: true, profile: true,
onDone: (err: Error | null, r?: regl.Regl | undefined): void => { onDone: (err: Error | null, r?: regl.Regl | undefined): void => {
if (err || !r) { if (err || !r) {

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7-scene", "name": "@antv/l7-scene",
"version": "2.0.23", "version": "2.0.24",
"description": "", "description": "",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -22,11 +22,11 @@
"author": "xiaoiver", "author": "xiaoiver",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@antv/l7-component": "^2.0.23", "@antv/l7-component": "^2.0.24",
"@antv/l7-core": "^2.0.23", "@antv/l7-core": "^2.0.24",
"@antv/l7-maps": "^2.0.23", "@antv/l7-maps": "^2.0.24",
"@antv/l7-renderer": "^2.0.23", "@antv/l7-renderer": "^2.0.24",
"@antv/l7-utils": "^2.0.23", "@antv/l7-utils": "^2.0.24",
"@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",

View File

@ -1,6 +1,6 @@
{ {
"name": "@antv/l7-source", "name": "@antv/l7-source",
"version": "2.0.23", "version": "2.0.24",
"description": "", "description": "",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
@ -24,8 +24,8 @@
"author": "lzxue", "author": "lzxue",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@antv/l7-core": "^2.0.23", "@antv/l7-core": "^2.0.24",
"@antv/l7-utils": "^2.0.23", "@antv/l7-utils": "^2.0.24",
"@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",

View File

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

View File

@ -51,9 +51,7 @@ export default class Point3D extends React.Component {
strokeWidth: 1, strokeWidth: 1,
}); });
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
const items = pointLayer.getLegendItems('color');
console.log(items);
console.log(pointLayer.getLegendItems('size'));
// scene.on('loaded', () => { // scene.on('loaded', () => {
// const newData = { // const newData = {
// type: 'FeatureCollection', // type: 'FeatureCollection',

View File

@ -37,7 +37,7 @@ export default class PointImage extends React.Component {
); );
let i = 0; let i = 0;
const data = await response.json(); const data = await response.json();
while (i < 50) { while (i < 1) {
const imageLayer = new PointLayer() const imageLayer = new PointLayer()
.source(data, { .source(data, {
parser: { parser: {
@ -46,9 +46,9 @@ export default class PointImage extends React.Component {
y: 'latitude', y: 'latitude',
}, },
}) })
// .shape('name', ['00', '01', '02']) .shape('name', ['00', '01', '02'])
.shape('name', 'text') // .shape('name', 'text')
.color('red') // .color('red')
.active(false) .active(false)
.size(20); .size(20);
// imageLayer.on('click', (e) => { // imageLayer.on('click', (e) => {

View File

@ -23,7 +23,7 @@ export default class HexagonLayerDemo extends React.Component {
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
map: new Mapbox({ map: new GaodeMap({
center: [120.19382669582967, 30.258134], center: [120.19382669582967, 30.258134],
pitch: 0, pitch: 0,
style: 'light', style: 'light',

View File

@ -162,9 +162,7 @@ export default class TextLayerDemo extends React.Component {
opacity, opacity,
}); });
scene.render(); scene.render();
setTimeout(() => { scene.exportPng();
scene.render();
}, 10);
}); });
rasterFolder.addColor(styleOptions, 'color').onChange((color: string) => { rasterFolder.addColor(styleOptions, 'color').onChange((color: string) => {
layer.color(color); layer.color(color);