地图视图组件

本条目介绍 地图视图组件 的公开用途。DeepSkill 当前公开目录说明:“在数据集展示的“视图”部分,将 GeoJSON 数据集渲染到交互式 Leaflet 地图上。安装 react-leaflet 和地图组件,然后为所选数据集渲染地图。当数据集的数据具有地理属性且需要在展示的默认元数据和下载选项之外提供地图视图时使用。” 适用场景包括写代码与代码审查、做图表与报表。本页根据公开目录资料和固定版本的上游仓库整理,建议使用前核对该版本的环境、工具、权限及数据处理要求。Skillπ 提供站方用途介绍与原站链接;原始 SKILL.md 和附件仅在对应许可允许时开放。

仓库
jeremylongshore/tons-of-skills-marketplace

安装方式

先用 Prompt 核对来源,也可切换到安装命令或下载可用的安装包。

安装方式

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "portaljs-add-map":https://skillpi.com/zh/skills/deepskill-8a15a46efb8f596047cb226886e1a2c2330d1f90b8839f9e433cd13a5d0a720e。安装前核对上游来源和版本:https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/6ea46b08dce892944db7c16f28d0b5308d402402/plugins/community/portaljs/skills/portaljs-add-map/SKILL.md。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

此命令从 GitHub 来源仓库获取指定技能。运行前请先查看源文件。

运行工具
npx skills add https://github.com/jeremylongshore/tons-of-skills-marketplace/tree/6ea46b08dce892944db7c16f28d0b5308d402402/plugins/community/portaljs/skills/portaljs-add-map --skill portaljs-add-map
许可协议: —

来源与配置

查看 GitHub 源码

jeremylongshore/tons-of-skills-marketplace固定提交 6ea46b08dce892944db7c16f28d0b5308d402402

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

本条目介绍 地图视图组件 的公开用途。DeepSkill 当前公开目录说明:“在数据集展示的“视图”部分,将 GeoJSON 数据集渲染到交互式 Leaflet 地图上。安装 react-leaflet 和地图组件,然后为所选数据集渲染地图。当数据集的数据具有地理属性且需要在展示的默认元数据和下载选项之外提供地图视图时使用。” 适用场景包括写代码与代码审查、做图表与报表。本页根据公开目录资料和固定版本的上游仓库整理,建议使用前核对该版本的环境、工具、权限及数据处理要求。Skillπ 提供站方用途介绍与原站链接;原始 SKILL.md 和附件仅在对应许可允许时开放。

↓ 0 下载 ↗ 0 分享点击

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
---
name: portaljs-add-map
description: Render a GeoJSON dataset on an interactive Leaflet map in the Views section of a dataset's showcase. Installs react-leaflet and a Map component, then renders the map for the chosen dataset. Use when a dataset's data is geographic and a map view is needed alongside the showcase's default metadata and download.
allowed-tools: Read, Write, Edit, Bash(npm:*), Bash(npx:*), WebFetch
version: 1.0.0
author: Datopian <hello@datopian.com>
license: MIT
compatibility: Claude Code with PortalJS portals (Next.js 14, React 18, Node 18+). Runs from any project via the plugin, a personal ~/.claude/commands install, or a portaljs clone.
tags:
  - portaljs
  - data-portal
  - map
  - geojson
  - leaflet
  - dataviz
---

# PortalJS — Add Map

## Overview

Add an interactive Leaflet map as a view on a dataset's **showcase** in a
`portaljs-catalog` portal. The skill installs `react-leaflet`/`leaflet` (added directly —
never `@portaljs/components`), writes a reusable `Map` component split across
`MapView.tsx` (the Leaflet code) and `Map.tsx` (a `dynamic(..., { ssr: false })` wrapper,
since Leaflet touches `window` at module load), and renders `<Map />` into the **Views**
section of the showcase route `pages/[owner]/[slug].tsx` for one chosen GeoJSON dataset.
The dataset should already carry `format: "geojson"` in `datasets.json`; if it doesn't
exist yet, the skill can copy the file and register it first.

## Prerequisites

- A scaffolded PortalJS portal (see `portaljs-new-portal`).
- The target dataset registered in `datasets.json` with `format: "geojson"` (see
  `portaljs-add-dataset`), or a GeoJSON source file/URL to register.
- Node 18+ and npm available in the portal directory.

## Instructions

The canonical, full step-by-step workflow is
[`.claude/commands/portaljs-add-map.md`](https://github.com/datopian/portaljs/blob/main/.claude/commands/portaljs-add-map.md) — the
single source of truth. Read and follow it when executing. Summary:

1. Gather input — dataset slug (or a GeoJSON source to register), portal directory. If any
   is missing, interview the user; never dead-end on a missing value.
2. Validate the portal directory (`datasets.json`, `package.json`,
   `pages/[owner]/[slug].tsx` must exist).
3. Resolve the dataset from `datasets.json`, or validate and register a new GeoJSON
   source (copy to `/public/data/`, append a manifest entry).
4. Install map dependencies: `npm install react-leaflet@^5 leaflet@^1.9` and
   `npm install -D @types/leaflet` (skip if already present).
5. Write `components/MapView.tsx` and `components/Map.tsx` (idempotent — skip if
   `Map.tsx` already exists).
6. Render `<Map />` into the Views section, gated on the dataset's `(namespace, slug)` so
   other showcases are unaffected. Extend an existing view-dispatch block, do not
   overwrite it.
7. Verify with `npx tsc --noEmit` (never `next build` against a live dev server).
8. Report the component, route, and dependency added.

## Output

- **Created:** `components/MapView.tsx` and `components/Map.tsx` (Leaflet wrapper, if
  absent); `public/data/<slug>.geojson` (only when registering a new dataset).
- **Modified:** `pages/[owner]/[slug].tsx` (import + gated `<Map />` in Views);
  `datasets.json` (only when registering a new dataset); `package.json`
  (`react-leaflet`, `leaflet`, `@types/leaflet`).
- **Verified:** `npx tsc --noEmit` passes.
- **Result:** the map renders at `/@<namespace>/<slug>` under a "Views" heading.

## Error Handling

| Symptom | Cause | Fix |
| --- | --- | --- |
| Dataset not found or not GeoJSON | Slug missing from `datasets.json` or `format` is tabular | List GeoJSON datasets and re-prompt; suggest `portaljs-add-chart` for tabular data. |
| Source fetch/copy fails | URL returns non-200 or local path missing | Report the HTTP status or missing path; ask for a corrected source. |
| "Not valid GeoJSON" | Parsed JSON `type` isn't a Feature/geometry type | Tell the user and point to `portaljs-add-dataset` for tabular data. |
| `tsc` failure | Bad import path or gating condition | Fix the first reported error before reporting success. |
| Map appears on every dataset | View not gated on `(namespace, slug)` | Wrap the `<Map />` render in the dataset check shown in the Instructions. |
| Features render in the wrong place | Data isn't WGS84 (EPSG:4326) lon/lat | Reproject the source data to WGS84 before adding. |
| Slow render | Thousands of features in one file (>5MB) | Simplify geometries (e.g. `mapshaper`) before adding. |

## Examples

### Example 1 — Map an already-registered dataset

```
/portaljs-add-map dataset=park-boundaries
```

### Example 2 — Register a local GeoJSON file and map it

```
/portaljs-add-map source=./data/bike-routes.geojson slug=bike-routes name="Bike Routes"
```

### Example 3 — Register a remote GeoJSON URL and map it

```
/portaljs-add-map source=https://example.com/districts.geojson slug=districts namespace=reference
```

## Resources

- Full workflow: [`.claude/commands/portaljs-add-map.md`](https://github.com/datopian/portaljs/blob/main/.claude/commands/portaljs-add-map.md)
- Map props and troubleshooting reference: [`references/reference.md`](references/reference.md)
- Related skills: `portaljs-add-dataset`, `portaljs-add-chart`, `portaljs-define-schema`
- react-leaflet documentation: <https://react-leaflet.js.org/>

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分 100。前四项来自 DeepSkill 收录的质量报告。

场景价值78/100
评分依据

为 PortalJS 数据门户的 GeoJSON 数据集提供交互式地图视图,解决地理数据可视化刚需

触发精准92/100
评分依据

触发描述清晰明确,准确描述了使用场景和边界条件

结构规范95/100
评分依据

文档结构完整,包含完整的执行流程、错误处理和示例

执行可靠90/100
评分依据

工具来源明确,参数正确,覆盖主要异常场景

证据可验 (前四项均值)89/100
计算方式

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • example.com
  • github.com
  • react-leaflet.js.org

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

risk · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。

来源与使用声明 SkillPi 的部分技能资料来自公开来源或创作者提交。第三方内容的权利归各自权利人所有。安装或运行前,请查看原站的许可、权限要求和使用风险。

来源与使用

请按详情页的作者、原始来源和许可证核对使用条件,运行前检查技能需要的权限。目录收录不等于已验证安装或安全性。