* feat: 补全 mapbox 模式下等面积点

* style: lint style
This commit is contained in:
YiQianYao 2022-02-11 10:47:58 +08:00 committed by GitHub
parent 1044b183c9
commit 8c0e3d16ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 5 deletions

View File

@ -127,8 +127,9 @@ export default class FillModel extends BaseModel {
if (
unit === 'meter' &&
version !== Version.L7MAP &&
version !== Version.GLOBEL &&
version !== Version.MAPBOX
version !== Version.GLOBEL
// &&
// version !== Version.MAPBOX
) {
this.isMeter = true;
this.calMeter2Coord();
@ -142,6 +143,26 @@ export default class FillModel extends BaseModel {
const [minLng, minLat, maxLng, maxLat] = this.layer.getSource().extent;
const center = [(minLng + maxLng) / 2, (minLat + maxLat) / 2];
const { version } = this.mapService;
if (version === Version.MAPBOX && window.mapboxgl.MercatorCoordinate) {
const coord = window.mapboxgl.MercatorCoordinate.fromLngLat(
{ lng: center[0], lat: center[1] },
0,
);
const offsetInMeters = 1;
const offsetInMercatorCoordinateUnits =
offsetInMeters * coord.meterInMercatorCoordinateUnits();
const westCoord = new window.mapboxgl.MercatorCoordinate(
coord.x - offsetInMercatorCoordinateUnits,
coord.y,
coord.z,
);
const westLnglat = westCoord.toLngLat();
this.meter2coord = center[0] - westLnglat.lng;
return;
}
// @ts-ignore
const m1 = this.mapService.meterToCoord(center, [minLng, minLat]);
// @ts-ignore

View File

@ -128,20 +128,29 @@ void main() {
float antialiasblur = -max(2.0 / u_DevicePixelRatio / a_Size, u_blur);
vec2 offset = (extrude.xy * (newSize + u_stroke_width) + textrueOffsets);
vec3 aPosition = a_Position;
if(u_isMeter < 1.0) {
// 不以米为实际单位
offset = project_pixel(offset);
} else {
// 以米为实际单位
antialiasblur *= pow(19.0 - u_Zoom, 2.0);
antialiasblur = max(antialiasblur, -0.01);
// offset *= 0.5;
if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {
aPosition.xy += offset;
offset.x = 0.0;
offset.y = 0.0;
}
}
// TODP: /abs(extrude.x) 是为了兼容地球模式
v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);
vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
// vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));
vec4 project_pos = project_position(vec4(aPosition.xy, 0.0, 1.0));
// gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));
if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x