antvis / L7

🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis engine.
https://l7.antv.antgroup.com
MIT License
3.67k stars 634 forks source link

移动端微信浏览器漂浮地图板块不显示相关layer #2615

Open CanonLs opened 1 month ago

CanonLs commented 1 month ago

问题描述

问题见Title 想实现漂浮地图板块 ,但是两台手机 ,微信版本相同,但是iOS版本不同 一个为iOS16.3.1 完全不显示layer 一个为iOS17.4 显示正常 代码技术栈为 react+vite+ts 没有任何其他功能代码,只是最基础的官网案例

import { useState, useEffect } from 'react'
import './App.css'
import { LineLayer, PointLayer, PolygonLayer, Scene } from '@antv/l7';
import type { LarkMapProps } from '@antv/larkmap';
import { LarkMap, useScene } from '@antv/larkmap';

const config: LarkMapProps = {
  mapType: 'Gaode',
  mapOptions: {
    style: 'light',
    center: [120.210792, 30.246026],
    zoom: 5,
    token: 'b311048a9319f4c449a6406ab9f14a2d',
  },
};

const ChildComponent = () => {
  const scene = useScene();

  useEffect(() => {
    scene.setMapStyle('dark');
    let lineDown: any, lineUp: any, textLayer: any;

    fetch('https://gw.alipayobjects.com/os/bmw-prod/ecd1aaac-44c0-4232-b66c-c0ced76d5c7d.json')
      .then((res) => res.json())
      .then((data) => {

        const texts: any = [];

        data.features.map((option: any) => {
          const { name, center } = option.properties;
          const [lng, lat] = center;
          texts.push({ name, lng, lat });
          return '';
        });

        textLayer = new PointLayer({ zIndex: 2 })
          .source(texts, {
            parser: {
              type: 'json',
              x: 'lng',
              y: 'lat',
            },
          })
          .shape('name', 'text')
          .size(14)
          .color('#0ff')
          .style({
            textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
            spacing: 2, // 字符间距
            padding: [1, 1], // 文本包围盒 padding [水平,垂直],影响碰撞检测结果,避免相邻文本靠的太近
            stroke: '#0ff', // 描边颜色
            strokeWidth: 0.2, // 描边宽度
            raisingHeight: 200000 + 150000 + 10000,
            textAllowOverlap: true,
          });
        scene.addLayer(textLayer);

        lineDown = new LineLayer().source(data).shape('line').color('#0DCCFF').size(1).style({
          raisingHeight: 200000,
        });

        lineUp = new LineLayer({ zIndex: 1 })
          .source(data)
          .shape('line')
          .color('#0DCCFF')
          .size(1)
          .style({
            raisingHeight: 200000 + 150000,
          });

        scene.addLayer(lineDown);
        scene.addLayer(lineUp);
        return '';
      });

    fetch('https://gw.alipayobjects.com/os/bmw-prod/d434cac3-124e-4922-8eed-ccde01674cd3.json')
      .then((res) => res.json())
      .then((data) => {
        const lineLayer = new LineLayer().source(data).shape('wall').size(150000).style({
          heightfixed: true,
          opacity: 0.6,
          sourceColor: '#0DCCFF',
          targetColor: 'rbga(255,255,255, 0)',
        });
        scene.addLayer(lineLayer);

        const provincelayer = new PolygonLayer({})
          .source(data)
          .size(150000)
          .shape('extrude')
          .color('#0DCCFF')
          .active({
            color: 'rgb(100,230,255)',
          })
          .style({
            heightfixed: true,
            pickLight: true,
            raisingHeight: 200000,
            opacity: 0.8,
          });

        scene.addLayer(provincelayer);

        provincelayer.on('mousemove', () => {
          provincelayer.style({
            raisingHeight: 200000 + 100000,
          });
          lineDown.style({
            raisingHeight: 200000 + 100000,
          });
          lineUp.style({
            raisingHeight: 200000 + 150000 + 100000,
          });
          textLayer.style({
            raisingHeight: 200000 + 150000 + 10000 + 100000,
          });
        });

        provincelayer.on('unmousemove', () => {
          provincelayer.style({
            raisingHeight: 200000,
          });
          lineDown.style({
            raisingHeight: 200000,
          });
          lineUp.style({
            raisingHeight: 200000 + 150000,
          });
          textLayer.style({
            raisingHeight: 200000 + 150000 + 10000,
          });
        });
        return '';
      });
  }, []);
  return null;
};

function App() {
  return (
    <LarkMap {...config} style={{ height: '300px' }}>
      <ChildComponent></ChildComponent>
    </LarkMap>
  )
}
export default App

重现链接

No response

重现步骤

No response

预期行为

我希望不同iOS版本都正常显示效果,but并没有

平台

屏幕截图或视频(可选)

2ed55ad543714497a2ff6db55b055288 4df557da82b27eef5420540e7602fb1f 显示正常的是iOS17.4 不正常的是iOS16.3.1

补充说明(可选)

如果是我代码问题麻烦大佬指点一下

github-actions[bot] commented 1 month ago

hi @CanonLs, welcome!

github-actions[bot] commented 1 month ago

Hi @CanonLs, Please star this repo if you find it useful! Thanks :star:! 你好~ @CanonLs 🌟 如果这个仓库对你有帮助,可以给我们点个star支持一下~你的支持对我们来说是最大的鼓励,感谢你的支持与点赞 🌟

lvisei commented 1 month ago

切换 renderer 为 regl 试试

const config: LarkMapProps = {
  mapType: 'Gaode',
  mapOptions: {
    style: 'light',
    center: [120.210792, 30.246026],
    zoom: 5,
    token: 'b311048a9319f4c449a6406ab9f14a2d',
  },
renderer: 'regl'
};