diff --git a/packages/core/src/services/coordinate/CoordinateSystemService.ts b/packages/core/src/services/coordinate/CoordinateSystemService.ts index 0cd4972d4f..d49362870b 100644 --- a/packages/core/src/services/coordinate/CoordinateSystemService.ts +++ b/packages/core/src/services/coordinate/CoordinateSystemService.ts @@ -8,6 +8,7 @@ import { CoordinateSystem, ICoordinateSystemService, } from './ICoordinateSystemService'; +import { transformOffset } from '../../../../maps/src/mapbox/utils'; const VECTOR_TO_POINT_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0]; @@ -106,7 +107,8 @@ export default class CoordinateSystemService } public getViewportCenter(): [number, number] { - return this.viewportCenter; + return transformOffset([Math.fround(this.viewportCenter[0]), Math.fround(this.viewportCenter[1])], window.map, 512) + // return this.viewportCenter; } public getViewportCenterProjection(): [number, number, number, number] { diff --git a/packages/core/src/shaders/projection.glsl b/packages/core/src/shaders/projection.glsl index fc3c4cb92a..67c1370d3b 100644 --- a/packages/core/src/shaders/projection.glsl +++ b/packages/core/src/shaders/projection.glsl @@ -52,7 +52,7 @@ vec4 project_offset(vec4 offset) { float dy = offset.y; dy = clamp(dy, -1., 1.); vec3 pixels_per_unit = u_PixelsPerDegree + u_PixelsPerDegree2 * dy; - return vec4(offset.xyz * pixels_per_unit, offset.w); + return vec4(offset.xyz , offset.w); } vec3 project_normal(vec3 normal) { @@ -105,8 +105,8 @@ vec4 project_position(vec4 position) { if (u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET || u_CoordinateSystem == COORDINATE_SYSTEM_P20_OFFSET) { - float X = position.x - u_ViewportCenter.x; - float Y = position.y - u_ViewportCenter.y; + float X = (position.x - u_ViewportCenter.x)* u_ZoomScale ; + float Y = ( position.y - u_ViewportCenter.y)* u_ZoomScale ; return project_offset(vec4(X, Y, position.z, position.w)); } if (u_CoordinateSystem < COORDINATE_SYSTEM_LNGLAT + 0.01 && u_CoordinateSystem >COORDINATE_SYSTEM_LNGLAT - 0.01) { diff --git a/packages/layers/src/plugins/DataMappingPlugin.ts b/packages/layers/src/plugins/DataMappingPlugin.ts index cdc8e2bb96..cec801bd7b 100644 --- a/packages/layers/src/plugins/DataMappingPlugin.ts +++ b/packages/layers/src/plugins/DataMappingPlugin.ts @@ -201,10 +201,10 @@ export default class DataMappingPlugin implements ILayerPlugin { // 调整数据兼容 SimpleCoordinates this.adjustData2SimpleCoordinates(mappedData); - if (this.mapService.map.getZoom() < 12) { - + // if (this.mapService.map.getZoom() < 12) { +console.log('adjustData2MapboxCoordinatesadjustData2MapboxCoordinates') this.adjustData2MapboxCoordinates(mappedData); - } + // } return mappedData; }