fix(map): use P20 offset coordinates

fix #94
This commit is contained in:
yuqi.pyq 2019-11-26 20:37:39 +08:00
parent 560c8fd4e4
commit 1e6bea4619
4 changed files with 33 additions and 48 deletions

View File

@ -12,7 +12,6 @@ uniform mat4 u_ModelMatrix;
varying vec4 v_color; varying vec4 v_color;
#pragma include "projection" #pragma include "projection"
#pragma include "project"
#pragma include "picking" #pragma include "picking"
void main() { void main() {
@ -20,7 +19,6 @@ void main() {
mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle)); mat2 rotationMatrix = mat2(cos(u_angle), sin(u_angle), -sin(u_angle), cos(u_angle));
vec2 offset = a_Position.xy * u_radius * rotationMatrix * u_coverage ; vec2 offset = a_Position.xy * u_radius * rotationMatrix * u_coverage ;
// vec2 lnglat = unProjectFlat(a_Pos.xy);
vec4 project_pos = project_position(vec4(a_Pos.xy + offset, 0, 1.0)); vec4 project_pos = project_position(vec4(a_Pos.xy + offset, 0, 1.0));
gl_Position = project_common_position_to_clipspace(project_pos); gl_Position = project_common_position_to_clipspace(project_pos);

View File

@ -46,6 +46,8 @@ export default class Viewport implements IViewport {
); );
mat4.lookAt(this.viewMatrix, eye, vec3.fromValues(0, 0, 0), up); mat4.lookAt(this.viewMatrix, eye, vec3.fromValues(0, 0, 0), up);
this.viewUncenteredMatrix = mat4.clone(this.viewMatrix);
// 移动相机位置 // 移动相机位置
mat4.translate( mat4.translate(
this.viewMatrix, this.viewMatrix,

View File

@ -317,15 +317,13 @@ export default class AMapService
}); });
// set coordinate system // set coordinate system
// if (this.viewport.getZoom() > LNGLAT_OFFSET_ZOOM_THRESHOLD) { if (this.viewport.getZoom() > LNGLAT_OFFSET_ZOOM_THRESHOLD) {
// // TODO:偏移坐标系高德地图不支持 pitch bear 同步 this.coordinateSystemService.setCoordinateSystem(
// this.coordinateSystemService.setCoordinateSystem( CoordinateSystem.P20_OFFSET,
// CoordinateSystem.P20_OFFSET, );
// ); } else {
// } else { this.coordinateSystemService.setCoordinateSystem(CoordinateSystem.P20);
// this.coordinateSystemService.setCoordinateSystem(CoordinateSystem.P20); }
// }
this.coordinateSystemService.setCoordinateSystem(CoordinateSystem.P20);
this.cameraChangedCallback(this.viewport); this.cameraChangedCallback(this.viewport);
} }
}; };

View File

@ -1,5 +1,5 @@
import { PointLayer, Scene } from '@antv/l7'; import { PointLayer, Scene } from '@antv/l7';
import { Mapbox } from '@antv/l7-maps'; import { AMap, Mapbox } from '@antv/l7-maps';
import * as React from 'react'; import * as React from 'react';
// @ts-ignore // @ts-ignore
import data from '../data/data.json'; import data from '../data/data.json';
@ -11,51 +11,38 @@ export default class Point3D extends React.Component {
this.scene.destroy(); this.scene.destroy();
} }
public componentDidMount() { public async componentDidMount() {
const response = await fetch(
'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json',
);
const pointsData = await response.json();
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
map: new Mapbox({ map: new AMap({
center: [120.19382669582967, 30.258134], center: [120.19382669582967, 30.258134],
pitch: 0, pitch: 0,
style: 'mapbox://styles/mapbox/streets-v9', style: 'light',
zoom: 1, zoom: 3,
}), }),
// map: new Mapbox({
// center: [120.19382669582967, 30.258134],
// pitch: 0,
// style: 'mapbox://styles/mapbox/streets-v9',
// zoom: 1,
// }),
}); });
const pointLayer = new PointLayer({ const pointLayer = new PointLayer({})
enablePicking: true, .source(pointsData)
enableHighlight: true, .shape('circle')
onHover: (pickedFeature: any) => { .size('mag', [1, 25])
// tslint:disable-next-line:no-console .color('mag', (mag) => {
console.log('Scene4', pickedFeature.feature.name); return mag > 4.5 ? '#5B8FF9' : '#5CCEA1';
}, })
});
pointLayer
.source(data)
.color('name', [
'#FFF5B8',
'#FFDC7D',
'#FFAB5C',
'#F27049',
'#D42F31',
'#730D1C',
])
.shape('subregion', [
'circle',
'triangle',
'square',
'pentagon',
'hexagon',
'octogon',
'hexagram',
'rhombus',
'vesica',
])
.size('scalerank', [5, 10])
.style({ .style({
opacity: 1.0, opacity: 0.3,
strokeWidth: 1,
}); });
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
scene.render();
this.scene = scene; this.scene = scene;
} }