提供 Svelte 与 MapLibre GL JS 结合的全屏地图示例
svelte-template-maplibre-gl-js — Svelte 文档模板
作者 maptiler
MapTiler 提供的 Svelte 地图应用起步模板,使用 MapLibre GL JS 展示全屏地图,需配置 MapTiler API Key。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 3
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
包含从克隆、安装依赖到本地运行的完整起步步骤
通过 .env 文件配置 MapTiler API Key
附带生产构建与 gh-pages 部署脚本说明
采用 MIT 许可,可自由使用、修改与分发代码
模板详细介绍
这是一个基于 Svelte 的 Web 地图应用起步模板,由 MapTiler 维护,采用 MIT 许可。模板以全屏地图为示例,演示如何在 Svelte 项目中结合 MapLibre GL JS 使用 MapTiler 地图服务。仓库通过 degit 从 sveltejs/template 生成,包含安装、配置 API Key、本地运行、生产构建以及部署到 gh-pages 的说明。
使用前需要自行准备 MapTiler API Key,并将其写入 .env 文件;模板本身不包含地图数据或地图服务,地图瓦片与样式依赖 MapTiler 云服务。模板的免费范围仅限 MIT 许可下的代码,MapTiler 服务、演示图片及其他第三方素材需按各自条款核对。
适合你的项目吗?
适用场景
- 在 Svelte 项目中快速搭建一个全屏地图页面
- 学习如何将 MapLibre GL JS 集成到 Svelte 组件中
- 作为需要 MapTiler 地图服务的 Svelte 应用起点
- 参考模板中的构建与 gh-pages 部署配置
适合人群
- 熟悉 Svelte 并希望接入地图功能的开发者
- 需要 MapLibre GL JS 与 Svelte 集成示例的团队
- 已拥有或计划申请 MapTiler API Key 的用户
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
克隆仓库后进入项目目录并运行 npm install 安装依赖
- 2
将 .env.example 复制为 .env,并把 YOUR_MAPTILER_API_KEY 替换为自己的 MapTiler API Key
- 3
运行 npm run dev 启动本地开发环境,默认地址为 http://localhost:5000/
- 4
运行 npm run build 进行生产构建,运行 node gh-pages.js 部署到 gh-pages 分支
- 5
MapTiler API Key 需在 MapTiler Cloud 账户页面获取
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 使用模板前必须自行获取并配置 MapTiler API Key,否则地图无法正常加载。
- 需要注册 MapTiler Cloud 账户才能获取 API Key,属于外部服务依赖。
- API Key 可免费创建,但地图服务受 MapTiler 免费额度限制,超出后可能产生费用。
- MapTiler 地图服务每月提供 100,000 次免费地图加载,超出该额度需按 MapTiler 条款付费。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
you will need to replace **YOUR_MAPTILER_API_KEY** with your own MapTiler API key
README 原文
Your MapTiler account access key is on your MapTiler [Cloud](https://cloud.maptiler.com/account/keys/) account page.
README 原文
If you don't have an API KEY, you can create it for free at https://www.maptiler.com/cloud/
README 原文
https://github.com/maptiler/svelte-template-maplibre-gl-js/blob/main/LICENSEhttps://github.com/maptiler/svelte-template-maplibre-gl-js/blob/main/README.mdStart building with 100,000 free map loads per month ・ No credit card required.
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-03。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 87 / 100
- 技术栈
- Svelte
- 网站类型
- 文档
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-01-20
- 截图检查日期
- 2026-10-03
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Svelte。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: [email protected] · 2026-10-03
查看当时使用的来源资料
SHA-256: 9ed8f1666e44d5e2077787f88e155aec9e0aee77165405cf2212b1d41ca402e4
2026-10-03T11:19:18.089Z
来源文件 / 仓库<img src="https://raw.githubusercontent.com/maptiler/maptiler-sdk-kotlin/main/Examples/maptiler-logo.png" alt="Company Logo" height="32"/> # Svelte map using MapLibre GL JS A quick way to start a web map application with Svelte using MapLibre GL JS. A simple fullscreen map application is used to showcase how to utilize MapTiler maps together with Svelte and MapLibre GL JS for your Svelte app. [](https://www.npmjs.com/package/maplibre-gl)  --- 📖 [Documentation](https://docs.maptiler.com/svelte/) 🌐 [Website](https://www.maptiler.com/) 🔑 [Get API Key](https://cloud.maptiler.com/account/keys/) --- <br> <details> <summary><b>Table of Contents</b></summary> <ul> <li><a href="#-installation">Installation</a></li> <li><a href="#-basic-usage">Basic Usage</a></li> <li><a href="#-related-examples">Examples</a></li> <li><a href="#-support">Support</a></li> <li><a href="#-contributing">Contributing</a></li> <li><a href="#-license">License</a></li> <li><a href="#-acknowledgements">Acknowledgements</a></li> </ul> </details> <p align="center"> <img src="./assets/svelte-maplibre-template.png" alt="Demo Screenshot" width="80%"/> <br> ## 📦 Installation Clone the repo to create a new Svelte project. Run in your command-line: ```shell git clone https://github.com/maptiler/svelte-template-maplibre-gl-js.git my-svelte-map ``` This project was generated with ```shell npx degit sveltejs/template my-svelte-project ``` <br> ## 🚀 Basic Usage ### Create an app Navigate to the newly created project folder **my-svelte-map** ```shell cd my-svelte-map ``` Install the NPM packages dependencies. Run in your command-line: ```shell npm install ``` ### API KEY Rename or copy the `.env.example` file to `.env` ```shell cp .env.example .env ``` Open the `.env` file, :warning: you will need to replace **YOUR_MAPTILER_API_KEY** with your own MapTiler API key. Your MapTiler account access key is on your MapTiler [Cloud](https://cloud.maptiler.com/account/keys/) account page. :information_source: If you don't have an API KEY, you can create it for free at https://www.maptiler.com/cloud/ ### Run To start your local environment, run: ```shell npm run dev ``` You will find your app on address http://localhost:5000/. Now you should see the app in your browser. ### Build To build for production, run: ```shell npm run build ``` ### gh-pages To deploy the app to the gh-pages branch, run: ```shell node gh-pages.js ``` <br> ## 💡 Related Examples - [How to display a map in Svelte using MapLibre GL JS](https://docs.maptiler.com/svelte/maplibre-gl-js/how-to-use-maplibre-gl-js/) - [Get Started with Svelte and MapLibre GL JS](https://docs.maptiler.com/svelte/maplibre-gl-js/get-started/) - [MapLibre GL JS geocoding control how to search places using Svelte](https://docs.maptiler.com/svelte/maplibre-gl-js/geocoding-control/) Check out the full list of [MapTiler examples](https://docs.maptiler.com/svelte/examples/) <br> ## 💬 Support - 📚 [Documentation](https://docs.maptiler.com/svelte/) - Comprehensive guides and API reference - ✉️ [Contact us](https://maptiler.com/contact) - Get in touch or submit a request - 🐦 [Twitter/X](https://twitter.com/maptiler) - Follow us for updates <br> --- <br> ## 🤝 Contributing We love contributions from the community! Whether it's bug reports, feature requests, or pull requests, all contributions are welcome: - Fork the repository and create your branch from `main` - If you've added code, add tests that cover your changes - Ensure your code follows our style guidelines - Give your pull request a clear, descriptive summary - Open a Pull Request with a comprehensive description <br> ## 📄 License This project is licensed under the MIT License – see the [LICENSE](./LICENSE) file for details. <br> ## 🙏 Acknowledgements This project is built on the shoulders of giants: - [MapTiler](https://www.maptiler.com/) – Maps for developers - [MapLibre GL JS](https://maplibre.org/maplibre-gl-js/docs/) – Open-source TypeScript library for publishing maps on your website - [Svelte](https://svelte.dev/) – Web development for the rest of us <br> <p align="center" style="margin-top:20px;margin-bottom:20px;"> <a href="https://cloud.maptiler.com/account/keys/" style="display:inline-block;padding:12px 32px;background:#F2F6FF;color:#000;font-weight:bold;border-radius:6px;text-decoration:none;"> Get Your API Key <sup style="background-color:#0000ff;color:#fff;padding:2px 6px;font-size:12px;border-radius:3px;">FREE</sup><br /> <span style="font-size:90%;font-weight:400;">Start building with 100,000 free map loads per month ・ No credit card required.</span> </a> </p> <br> <p align="center"> 💜 Made with love by the <a href="https://www.maptiler.com/">MapTiler</a> team <br /> <p align="center"> <a href="https://www.maptiler.com/">Website</a> • <a href="https://docs.maptiler.com/svelte/">Documentation</a> • <a href="https://github.com/maptiler/get-started-svelte-maplibre-gl-js">GitHub</a> </p>
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

sveltepress
Sveltepress 是一个建立在 SvelteKit 之上的文档与博客静态站点生成工具,思路接近 VitePress,但保留了完整的 SvelteKit 能力面(SSR、适配器、服务端路由、hooks)。
Svelte · 工具站

minimal-mistakes
:triangular_ruler: Jekyll theme for building a personal site, blog, project documentation, or portfolio.
Jekyll · 作品集

hugo-book
Hugo Book 是一个面向文档场景的 Hugo 主题,定位很直接:把文档站点做得像一本朴素的书。
Hugo · 文档

jekyll-TeXt-theme
💎 🐳 A super customizable Jekyll theme for personal site, team site, blog, project, documentation, etc.
Jekyll · 博客

docsy
Hugo theme for open source documentation
Hugo · 文档

hextra
Hextra 是一个 Hugo 主题,定位在文档站与博客之间:既提供侧边栏导航、目录、面包屑、分页这类文档站结构,也能承载博客内容。
Hugo · 文档
