为什么在React中使用Leaflet进行平移和缩放速度很慢?

3

我有一个相对简单的应用程序,使用leaflet.js渲染了约3000个点。它的渲染速度相当快,但是平移和缩放非常慢。

通过查看Chrome中的性能工具,发现大部分时间都花费在重新计算样式上,但这并没有什么帮助。

      <LeafletMap
        center={[50, 10]}
        zoom={6}
        maxZoom={10}
        preferCanvas={true}
      >
        <TileLayer
          url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
        />
        {this.state.locations.map( (location, index) => {
            return (
              <Marker position={[location.latitude, location.longitude]}>
                <Popup>
                  Popup for any custom information.
                </Popup>
              </Marker> 
            )
        })}
    </LeafletMap>

你试过在画布渲染器上将你的标记替换为圆形标记吗? - undefined
1
谢谢你的建议。我会尝试一下。我之前发布的大部分内容都是错误的。事实证明这与React完全无关。我已经相应地更新了问题。 - undefined
1个回答

1

你有没有尝试使用leaflet的preferCanvas而不是PixiOverlay? - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接