首页 / 浏览问题 / WebGIS / 问题详情
iClient for Leaflet 设置剪切问题
36EXP 2025年11月14日

设置如下数组的多边形对象进行地图剪切,加载后地图一直为空白,代码如下:

const clipBounds = [
  [564854.2357606415171176, 3509794.7244224171154201],
  [556241.7916950165526941, 3502601.9139939770102501],
  [559980.1602729525184259, 3492806.4418973671272397],
  [570059.5590970074990764, 3488642.1832282668910921],
  [579902.3523148654494435, 3490866.2759265368804336],
  [583404.1152866025222465, 3498248.370839926879853],
  [583404.1152866025222465, 3504210.8321161270141602],
  [578336.8894381294958293, 3509285.9060525870881975],
  [573135.4319775884505361, 3511687.5692720068618655],
  [564854.2357606415171176, 3509794.7244224171154201]
];

// 将投影坐标转换为经纬度坐标
const latLngs = [];
for (let j = 0; j < clipBounds.length; j++) {
  if (this.crs !== null) {
    // 使用CRS对象将坐标从投影坐标转换为经纬度坐标
    latLngs[j] = this.crs.unproject(L.point(clipBounds[j]));
  } else {
    // 如果没有CRS对象,则直接使用坐标(注意坐标顺序可能需要调整)
    latLngs[j] = [clipBounds[j][1], clipBounds[j][0]]; // [lng, lat] -> [lat, lng]
  }
}
console.log("latLngs", latLngs);

let ll = L.polygon(latLngs).addTo(this.map);
let mapLayer = L.supermap.tiledMapLayer(this.mapData[i].url_map, {
  zIndex: 1,
  clipRegionEnabled: true,
  clipRegion: ll
});
this.mapLayerGroup.addLayer(mapLayer);

1个回答

您看看tileImage请求是不是报错了,如果请求报错,可以按照博客将GET请求重写为POST请求:

https://blog.csdn.net/supermapsupport/article/details/121488715

1,421EXP 2025年11月14日
没有看到报错信息,就是整个地图都没有显示
...