geojson-vt 与反应传单

问题描述 投票:0回答:1

有人有使用 geojson-vt 的 React-leaflet 项目的准系统仓库示例吗?

我有一个react-leaflet项目,它有一个13 MB的geoJSON文件。我不知道如何使用 React-leaflet 的 geojson 标签让它渲染得更快。我希望 geojson-vt 是答案。

reactjs leaflet geojson react-leaflet
1个回答
0
投票
/**
 * @file Component to render geojson as vector tile with `geojson-vt`.
 * @name GeoJSONVtLayer.js
 */
import L from "leaflet";
import {
  createTileLayerComponent,
  updateGridLayer,
  withPane,
} from "@react-leaflet/core";
import geojsonvt from "geojson-vt";
window.geojsonvt = geojsonvt;
// eslint-disable-next-line import/first
import {} from "leaflet-geojson-vt";

export const GeoJSONVtLayer = createTileLayerComponent(function createGridLayer(
  { geoJSON, ...options },
  context
) {
  return {
    instance: L.gridLayer.geoJson(geoJSON, withPane(options, context)),
    context
  };
},
updateGridLayer);
© www.soinside.com 2019 - 2024. All rights reserved.