antvis / antvis/L7

使用L7加载的线数据与Mapbox加载的线数据叠加存在偏移

Open
#2,700 4 comments 1 reaction 1 assignee View on GitHub

@lzxue is already working on this.

Since Apr 21, 2025.

bug
Dominant language
TypeScript
Stars
4.1k
Forks
656
PR merge metrics
No merged PRs in 30d

Description

使用L7加载的线数据与Mapbox加载的线数据叠加存在偏移,在较小层级下看不出来,大概到20级别之后,可以明显看到两份线数据图层明显偏移。

![Image](https://github.com/user-attachments/assets/c08e0864-dc81-4070-85c4-a34bc39407d0)

可以到这里在线运行示例:https://iclient.supermap.io/examples/mapboxgl/editor.html#01_tiledMapLayer_4490

代码参考:
`






body {
margin: 0;
padding: 0;
width: 100%;
height: 100vh;
overflow: hidden;
}
#map {
width: 100%;
height: 100%;
}




var host = window.isLocal ? window.server : 'https://iserver.supermap.io';
var tileURL = host + '/iserver/services/map-china400/rest/maps/ChinaDark/zxyTileImage.png?z={z}&x={x}&y={y}';

var map = new mapboxgl.Map({
container: 'map',
style: {
version: 8,
sources: {
'raster-tiles': {
type: 'raster',
tiles: [tileURL],
tileSize: 256
}
},
layers: [
{
id: 'simple-tiles',
type: 'raster',
source: 'raster-tiles',
minzoom: 0,
maxzoom: 22
}
]
},
center: [120.15, 30.246],
zoom: 13.5,
});

map.on('load', function () {
// 加载并添加基础路线图层(Mapbox原生)
fetch('https://iclient.supermap.io/web/data/L7/40ef2173-df66-4154-a8c0-785e93a5f18e.json')
.then((res) => res.json())
.then((data) => {
// 添加粗体基础路线
map.addSource('base-route', {
type: 'geojson',
data: data
});

map.addLayer({
id: 'base-route-layer',
type: 'line',
source: 'base-route',
layout: {
'line-join': 'round',
'line-cap': 'round'
},
paint: {
'line-color': '#1565C0', // 深蓝色
'line-width': 6, // 较粗的线宽
'line-opacity': 0.9,
'line-gap-width': 2 // 为贴图图层留出空间
}
});

// 添加白色边框增强对比度
map.addLayer({
id: 'route-border',
type: 'line',
source: 'base-route',
layout: {
'line-join': 'round',
'line-cap': 'round'
},
paint: {
'line-color': 'white',
'line-width': 8,
'line-opacity': 0.5,
'line-translate': [0, 0]
}
}, 'base-route-layer'); // 确保在基础路线图层下方
});

// 加载L7贴图图层
map.getL7Scene().then((scene) => {
// 使用更醒目的箭头图标
scene.addImage('arrow-highlight', '../img/ce83fc30-701f-415b-9750-4b146f4b3dd6.svg');

fetch('https://iclient.supermap.io/web/data/L7/40ef2173-df66-4154-a8c0-785e93a5f18e.json')
.then((res) => res.json())
.then((data) => {
var layer = new mapboxgl.supermap.L7Layer({ type: 'LineLayer' });
layer
.getL7Layer()
.source(data)
.size(4) // 增大尺寸
.shape('line')
.texture('arrow-highlight')
.color('rgb(255, 215, 0)') // 改为金色箭头
.animate({
interval: 0.8, // 加快动画速度
duration: 0.8,
trailLength: 3 // 增加流线长度
})
.style({
opacity: 0.8, // 提高不透明度
lineTexture: true,
iconStep: 15, // 增大箭头间距
borderWidth: 0.6, // 加粗边框
borderColor: 'rgba(255, 0, 0, 0.7)' // 红色边框增强对比
});
map.addLayer(layer);
});
});
});

`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.