npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@taichina/map-sdk

v1.0.28

Published

基于 GIS 的铁路业务地图 SDK。

Readme

teee-map-sdk

基于 maplibre-gl 封装的铁路 GIS 业务地图 SDK,面向太昌 GIS 业务流提供开箱即用的地图初始化、图层管理、要素状态控制、加密瓦片及离线包支持。

安装

npm install @taichina/map-sdk

快速开始

import { TeeeMap } from "@taichina/map-sdk";
import maplibregl from "maplibre-gl";

const teeeMap = new TeeeMap("map-container");

// CTC 施工推演图
teeeMap.createCTCMap("ST-001", "https://tiles.example.com/{z}/{x}/{y}", [
  "track",
  "signal",
  "switch",
]);

// 获取底层 maplibre 实例
const map = teeeMap.getMap();

引入方式

<!-- UMD -->
<script src="teee-sdk/teee-map-sdk.umd.js"></script>
<script>
  const map = new TeeeMapSDK.TeeeMap("map");
</script>
// ES Module
import { TeeeMap } from "@taichina/map-sdk";

API

构造函数

new TeeeMap(container: string | HTMLElement)

| 参数 | 说明 | |------|------| | container | DOM 元素 ID 或 HTMLElement |

地图创建方法

| 方法 | 说明 | |------|------| | createCTCMap(stcode, url, layers) | CTC 施工推演 / 站场平面图 | | createCTCEncryptedMap(stcode, url, layers) | 加密 CTC 图 | | createGraphMap(stcode, url, layers) | 普通站场平面图 | | createGraphEncryptedMap(stcode, url, layers) | 加密平面图 | | createGeomMap(stcode, url, layers) | 地理图(EPSG:4326 / 4490) | | createGeomEncryptedMap(stcode, url, layers) | 加密地理图 | | createRasterMap(url) | 影像 / 栅格底图 | | createEncryptedRasterMap(url) | 加密栅格图 | | createRSWPMap(url) | 人员定位图(栅格 + GeoJSON) | | createRAGEMap(url, subUrl, code) | 信息所综合业务图 | | createMbtilesMap(url, layers) | MBTiles 离线包 |

数据源管理

| 方法 | 说明 | |------|------| | addGeoJsonSource(id, data?) | 添加 GeoJSON 源 | | addVectorTileSource(id, url) | 添加矢量瓦片源 | | addRasterTileSource(id, url) | 添加栅格瓦片源 | | updateGeoJsonSource(id, data) | 更新 GeoJSON 数据 | | removeSource(id) | 移除数据源 |

图层管理

| 方法 | 说明 | |------|------| | addGeoJsonLayer(layerId, sourceId, type?, paint?, layout?) | 添加 GeoJSON 图层 | | updateLayerStyle(id, paint) | 动态修改图层 paint 样式 | | removeLayer(id) | 移除图层 |

要素状态管理(CTC 业务)

| 方法 | 说明 | |------|------| | stashAllFeature() | 缓存当前视口全部要素(首次 idle 自动执行) | | updateFeatureState(code, state) | 更新要素状态,如封锁、停电、选中等 | | initCTCFeatureState(feature) | 为单个要素初始化 CTC 业务状态 |

teeeMap.updateFeatureState("DG-102", {
  state: "1",     // 股道封锁
  select: true,   // 选中
});

交互事件

teeeMap.onFeatureClick("layer-id", (feature, lngLat) => {
  console.log(feature.properties.code);
});

绘制工具

地图 load 完成后,drawTool 会自动挂载:

const draw = teeeMap.drawTool;
draw.changeMode("polygon");        // 切换绘制模式
draw.onFinish((geojson) => {...}); // 绑定完成回调
draw.clear();                      // 清空画布

其他

| 方法 | 说明 | |------|------| | getMap() | 获取底层 maplibregl.Map 实例 | | getMapConfigs() | 获取当前 MapForgeConfig | | destroy() | 销毁地图实例 |

构建

npm run build          # 输出到 teee-sdk/

项目结构

├── src/
│   ├── index.ts          # SDK 入口,导出 TeeeMap
│   ├── teee-map/         # 核心 SDK(git 子模块,含详细设计文档)
│   └── map-const/        # 地图常量 & 枚举(git 子模块)
├── teee-sdk/             # 构建产物(.es.js / .umd.js / .css)
├── SDK/                  # 示例 HTML 页面 + SDK 副本
├── vite.config.ts        # Vite library mode 配置
└── tsconfig.json

核心 SDK 采用工厂模式:MapForge 生成配置 → SourceFactory 生成数据源 → LayerFactory 生成图层 → ToolFactory 注册交互工具。详见 src/teee-map/DESIGN.md

依赖

| 包 | 版本 | 说明 | |------|------|------| | maplibre-gl | ^5.24.0 | peer,需自行安装 | | @turf/bbox | ^7.0.0 | GeoJSON 包围盒计算 | | @watergis/maplibre-gl-terradraw | ^1.13.1 | 绘制工具 | | pako | ^2.1.0 | MBTiles Gzip 解压 |