百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

react-map-components-maplibre

> 前端框架
开源

一个用于声明式 GIS 应用程序开发的 React 组件框架。

191 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

一个用于声明式 GIS 应用程序开发的 React 组件框架。

MapComponents

@mapcomponents is a monorepo containing react component libraries for declarative GIS application development.

Links

  • Documentation: https://mapcomponents.github.io/react-map-components-maplibre/storybook-composition/
  • Catalogue: https://www.mapcomponents.org/

Getting started

Use our Codesandbox template to quickly try out this library without any setup required. https://codesandbox.io/s/base-template-n0vp9

How to use @mapcomponents/react-maplibre in a new project

The easiest way to start a new project using this framework is to bootstrap a react application using our vite-template.

Requirements:

  1. node.js >=20

Run the following commands in the terminal:

bash
npm create mapcomponents-app@latest myApp
npm i
npm run dev

This will start a development server that serves the mapcomponents app on port 5174 of your local machine as well as a browser tab with live reload enabled. This reloads the affected parts of the application if changes are detected to the corresponding files in the filesystem. Open the project folder in the IDE of your choice and start building your map client.

Adding data to the map

The easiest way to add data to the map is using GeoJSON data and the MlGeoJsonLayer component. The MlGeoJsonLayer component is designed to require only the geojson property to be set, while it provides properties to fully customize it to your needs.

Insert the following code in your app below index.tsx to add a GeoJSON layer to your map.

javascript
import MlGeoJsonLayer from '@mapcomponents/react-maplibre';

const geojson_data = {
	"type": "Feature",
	"properties": {},
	"geometry": {
		"coordinates": [
			[
				[0.7415817264899545, 56.91203727013931],
				[0.7743616447289128, 55.2757658775181],
				[4.609612078732766, 55.23840364745948],
				[4.642391996971725, 56.91203727013931],
				[0.7415817264899545, 56.91203727013931]
			]
		],
		"type": "Polygon"
	}
}

And add the following within the JSX.

javascript

Add any of our packages to your project

In this case, navigate to your project folder in a terminal and execute the following steps:

  1. Add @mapcomponents/{package} as a dependency to your project using npm i @mapcomponents/{package}.
  2. Add the MapComponentsProvider (named export of this module) to your applications react-DOM where it makes sense. Only children of this component will be able to render a map canvas or interact with a maplibre-gl instance. Place it in the index.js entrypoint if your application is a dedicated map app and all components have a high probability to interact with the maplibre-gl instance. Place it somewhere higher in the JSX tree if the map constitutes only a small portion of your app and components outside of the MapComponentsProvider have no need to interact with the map instance.
  3. Add a MapLibreMap component to the react-DOM wherever the map canvas is supposed to be placed.

Please take a look at our storybooks and the code examples provided in the {ComponentName}.stories.tsx files next to the Components in the ./src/components/ folder.

more links

  • @mapcomponents/react-maplibre storybook: https://mapcomponents.github.io/mapcomponents/react-maplibre/
  • @mapcomponents/deck-gl storybook: https://mapcomponents.github.io/mapcomponents/deck-gl/
  • @mapcomponents/ra-geospatial storybook: https://mapcomponents.github.io/mapcomponents/ra-geospatial/
  • @mapcomponents/react-maplibre-lab storybook: https://mapcomponents.github.io/react-map-components-maplibre-lab

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptgeojsongisleafletmapbox-gl-js

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架