@apple/mapkit-loader

中文文档
1.0.0发布于 2026/06/09MITTypeScriptESM + CJS构建来源已验证近 30 天下载 30.4万

Apple MapKit JS Loader

原始使用文档
文档目录4 节
  1. Installation
  2. Documentation
  3. Example using MapKit JS Loader
  4. Advanced server-side rendering integration

MapKit Loader

Loads Apple MapKit JS script dynamically from Apple MapKit CDN. This package exposes the returned mapkit object with type definitions.

Installation

Available via npm as the package @apple/mapkit-loader.

npm i @apple/mapkit-loader

Documentation

For documentation on MapKit JS, see the Apple MapKit JS Documentation.

Example using MapKit JS Loader

import { load } from "@apple/mapkit-loader";

const mapkit = await load({
  token: "YOUR_MAPKIT_TOKEN",
  language: "en-US",
  libraries: ["map", "annotations"],
});

The load() function returns a Promise that would resolve to the mapkit object. The awaited mapkit object is available with map and annotations libraries loaded.

const map = new mapkit.Map(container);
const annotation = new mapkit.MarkerAnnotation(new mapkit.Coordinate());
map.addAnnotation(annotation);

Advanced server-side rendering integration

It is possible to generate a static <script> tag in server-side rendering, and allows the load() call to "pick it up" later during application load. Doing so starts loading MapKit JS bundles before the application loads.

See descriptions of renderHTMLAttributes() and renderToHTMLString() for details.

版本与发布记录

@apple/mapkit-loader 共发布 4 个版本,首次发布于 2025/10/31;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.0latest2026/06/094 个月前
0.2.22026/06/025 个月前
0.2.12025/10/311 年前
0.1.02025/10/311 年前

关于 @apple/mapkit-loader 的常见问题

@apple/mapkit-loader 是什么?

Apple MapKit JS Loader

如何安装 @apple/mapkit-loader?

在项目目录运行 npm install @apple/mapkit-loader,或使用 pnpm add / yarn add / bun add。

@apple/mapkit-loader 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@apple/mapkit-loader 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@apple/mapkit-loader 可以商用吗?

@apple/mapkit-loader 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@apple/mapkit-loader 的下载量有多少?

根据 npm 官方下载统计,@apple/mapkit-loader 在 2026/10/07 – 2026/11/05 这 30 天内被下载 304,286 次,日均约 10,143 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@apple/mapkit-loader 还在维护吗?

最新版本 1.0.0 发布于 2026/06/09(4 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 2 个;首次发布于 2025/10/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。