首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有react-leaflet的geojson-vt

具有react-leaflet的geojson-vt
EN

Stack Overflow用户
提问于 2021-01-13 07:00:02
回答 1查看 190关注 0票数 0

有谁有使用geojson-vt的react-leaflet项目的barebone存储库的示例吗?

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

EN

回答 1

Stack Overflow用户

发布于 2021-05-12 14:52:32

代码语言:javascript
复制
/**
 * @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);

Demo

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65693307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档