专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题轩辕镜像免费版
其他
关于我们网站地图
热门搜索:
mbgl-renderer

consbio/mbgl-renderer

consbio

Static renderer for Mapbox GL

2 次收藏下载次数: 0状态:社区镜像维护者:consbio仓库类型:镜像最近更新:4 年前
轩辕镜像,让镜像更快,让人生更轻。点击查看
镜像简介
标签下载
镜像标签列表与下载命令
轩辕镜像,让镜像更快,让人生更轻。点击查看

Static Map Renderer using Mapbox GL

![Build Status]([***]

![Coverage Status]([***]

Create static map images using Mapbox GL with a command-line interface, an HTTP interface, and a NodeJS API.

WARNING

This project depends on the Mapbox GL bindings for NodeJS, which are no longer maintained by Mapbox. These require NodeJS 10, which is now beyond end of life for that version.

We are monitoring the ecosystem for other alternatives (e.g., MapLibre) but have not yet identified a suitable replacement for the NodeJS bindings from Mapbox. Feel free to create an issue to report discovery of a suitable replacement.

As such, this project is largely in maintenance mode, and we are unlikely to make major changes in functionality.

Features:

  • Render static maps using NodeJS with https://github.com/mapbox/mapbox-gl-native
  • Supports raster and vector tiles
  • Compatible with Mapbox tiles (don't forget attribution) and other hosted tile providers
  • Use locally hosted mbtiles
  • Add GeoJSON overlays to your maps
  • Supports high DPI rendering
  • Also available for use in Docker

Blog post describing the background and goals in a bit more detail.

One of the nifty features of this package is that you can use locally hosted mbtiles files with your raster or vector tiles. This saves ***able time during rendering compared to using map services over the web.

This package is intended to help with generating static maps for download or use in reports, especially when combined with your own styles or overlays.

If you are only using hosted Mapbox styles and vector tiles, please use the Mapbox Static API instead; it is more full featured and more appropriate for static Mapbox maps.

Attribution

Please make sure to give appropriate attribution to the data sources and styles used in your maps, in the manner that those providers specify.

If you use Mapbox styles or hosted tiles, make sure to include appropriate attribution in your output maps.

Installation

npm add mbgl-renderer or npm install mbgl-renderer

Supported versions of NodeJS:

  • 10

Only NodeJS versions with @mapbox/mapbox-gl-native binaries built by Mapbox are supported via npm install, otherwise you need to build @mapbox/mapbox-gl-native from source yourself. See https://github.com/mapbox/mapbox-gl-native/blob/master/platform/node/DEVELOPING.md for more information.

On a server, in addition to build tools, you need to install a GL environment. See the Dockerfile and entrypoint.sh for an example setup.

Usage

Style JSON:

The primary input to every map rendering method below is a Mapbox GL Style JSON file. For full reference on this format, please see the Mapbox documentation.

Labels

In order to use text labels, you need to include glyphs in your Style JSON (sibling of sources)

To use Mapbox hosted glyphs (a Mapbox token is required):

json
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf"

You can also use https://github.com/openmaptiles/fonts:

json
"glyphs": "http://fonts.openmaptiles.org/{fontstack}/{range}.pbf",

In either case, you must make sure that the font you specify is available from that provider. See tests/fixtures/example-style-geojson-label.json for an example of adding labels based on coordinates specified in GeoJSON.

NodeJS API:

The following examples assume that you are using babel to provide ES6 features.

import render from 'mbgl-renderer'

import style from `tests/fixtures/example-style.json`
// style JSON file with MapBox style.  Can also be opened and read instead of imported.

const width = 512
const height = 256
const center = [-79.86, 32.68]
const zoom = 10

render(style, width, height, { zoom, center })
    .then((data) => {
        fs.writeFileSync('test.png', data)
    }))

You can also provide bounds instead of center and zoom:

const width = 512
const height = 256
const bounds = [-80.23, 32.678, -79.73, 32.891]

render(style, width, height, { bounds })
    .then((data) => {
        fs.writeFileSync('test.png', data)
    }))

If you provide bounds you can also provide padding to add that many pixels to each side of the rendered image. These pixels are padded to the inside of the image, meaning that the resulting image matches the width and height you provide, but is zoomed out to allow padding around the edges.

const width = 512
const height = 256
const bounds = [-80.23, 32.678, -79.73, 32.891]
const padding = 25

render(style, width, height, { bounds, padding })
    .then((data) => {
        fs.writeFileSync('test.png', data)
    }))

padding must be integers and not be greater than 1/2 of width or height, whichever is smaller. You can provide a negative padding to over-zoom the image.

You can also supply a pixel ratio for High DPI screens, typically > 1 (max of 31 has been tested):

const width = 512
const height = 256
const center = [-79.86, 32.68]
const zoom = 10
const ratio = 2

render(style, width, height, { zoom, center, ratio })
    .then((data) => {
        fs.writeFileSync('test.png', data)
    }))

You can also provide an alternative bearing (0-360) or pitch (0-60):

const width = 512
const height = 256
const center = [-79.86, 32.68]
const zoom = 10
const bearing = 90
const pitch = 30

render(style, width, height, { zoom, center, bearing, pitch })
    .then((data) => {
        fs.writeFileSync('test.png', data)
    }))

If your style includes a Mapbox hosted source (e.g., "url": "mapbox://mapbox.mapbox-streets-v7"), you need to pass in your Mapbox access token as well:

render(style, width, height, { bounds, token: '<your access token>' })
    .then((data) => {
        fs.writeFileSync('test.png', data)
    }))

Command line interface:

  Usage: mbgl-render <style.json> <img_filename> <width> <height> [options]

  Export a Mapbox GL map to image.  You must provide either center and zoom, or bounds.

  Options:

    -V, --version                         output the version number
    -c, --center <longitude,latitude>     center of map (NO SPACES)
    -z, --zoom <n>                        Zoom level
    -r, --ratio <n>                       Pixel ratio
    -b, --bounds <west,south,east,north>  Bounds (NO SPACES)
    --padding <padding>                   Number of pixels to add to the inside of each edge of the image.  Can only be used with bounds option.
    --bearing <degrees>                   Bearing in degrees (0-360)
    --pitch <degrees>                     Pitch in degrees (0-60)
    -t, --tiles <mbtiles_path>            Directory containing local mbtiles files to render
    --token <mapbox access token>         Mapbox access token (required for using Mapbox styles and sources)
    -h, --help                            output usage information

To render an image using center (NO spaces or brackets) and zoom:

mbgl-render tests/fixtures/example-style.json test.png 512 256 -c -79.86,32.68 -z 10

To render an image using bounds (NO spaces or brackets):

mbgl-render tests/fixtures/example-style.json test.png 512 256 -b -80.23,32.678,-79.73,32.891

To render an image using bounds and padding:

mbgl-render tests/fixtures/example-style.json test.png 512 256 -b -80.23,32.678,-79.73,32.891 --padding 25

To use local mbtiles tilesets:

mbgl-render tests/fixtures/example-style-mbtiles-source-vector.json test.png 1024 1024 -z 0 -c 0,0 -t tests/fixtures

To use an Mapbox hosted style (see attribution above!):

mbgl-render mapbox://styles/mapbox/outdoors-v10 test.png 1024 1024 -c 0,0 -z 0 --token <your mapbox token>

Note: support for Mapbox hosted styles is still ***ed experimental.

Static image server

You start this from the command line:

  Usage: mbgl-server [options]

  Start a server to render Mapbox GL map requests to images.

  Options:

    -V, --version               output the version number
    -p, --port <n>              Server port
    -t, --tiles <mbtiles_path>  Directory containing local mbtiles files to render
    -v, --verbose               Enable request logging
    -h, --help                  output usage information

To start this on port 8080 with local tiles in tests/fixtures:

mbgl-static-server -p 8080 -t tests/fixtures

You can also start this via npm start but you must use the -- spacer before passing argmuents:

npm start -- --port 8080 --tiles tests/fixtures

Making requests

In your client of choice, you can make either HTTP GET or POST requests.

GET requests:

height and width are integer values zoom is a floating point value ratio is an integer value center if provided must be a longitude,latitude with floating point values (NO spaces or brackets) bounds if provided must be west,south,east,north with floating point values (NO spaces or brackets) padding if provided must be an integer value that is less than 1/2 of width or height, whichever is smaller. Can only be used with bounds. bearing is a floating point value (0-360)pitchis a floating point value (0-60)token` if provided must a string

Your style JSON needs to be URL encoded:

CODE_TOKEN_17

If your style JSON points to local tilesets, you must have started the server up using those local tilesets.

To test the server from the command line, for example with the excellent tool httpie with the style file tests/fixtures/example-style-mbtiles-source.json:

CODE_TOKEN_18

POST requests:

You can do a POST request with all of the above parameters in the body of the request, and the style can be passed directly as JSON instead of URL encoded.

POST may be necessary where your style JSON file exceeds the maximum number of characters allowed in a GET request URL.

Development

Use npm run watch to start up a file watcher to recompile ES6 files in src/ to ES5 files that are executable in Node in dist/. These are compiled using babel.

Testing

Tests are run using jest. Right now, our coverage is not great and tests only exercise the core functionality of the render function.

Tests require a valid Mapbox API token. Set this in .env.test file in the root of the repository:

CODE_TOKEN_19

To run tests:

CODE_TOKEN_20

This uses the pixelmatch package to determine if output images match those that are expected. This may fail when rendered on different machines for reasons we have not completely sorted out, so don't necessarily be alarmed that tests are failing for you - check the outputs.

Docker

Pull the latest image from https://hub.docker.com/r/consbio/mbgl-renderer:

CODE_TOKEN_21

To run mbgl-server in the docker container on port 8080:

CODE_TOKEN_22

Mount your local tiles directory to /app/tiles in the container to use these in the server or CLI:

CODE_TOKEN_23

Build your own image:

Build your own docker container with name <image_name>:

CODE_TOKEN_24

Headless servers

In order to use this package on a headless server, you need to use xvfb. See docker/Dockerfile and docker/entrypoint.sh for the basic configuration.

Changes

0.7.3

  • actually skip request logging for docker health check
  • avoid nesting error messages
  • upgraded JS dependencies

Potentially breaking:

  • @mapbox/geo-viewport 0.4.1 included a fix for calculating center points, which causes a small change in the center and zoom level automatically calculated here when bounds are provided for rendering. If you depend on precise control over how bounds are used for rendering, please check the outputs after upgrading.

0.7.2

  • skip request logging for routes that do not exist (e.g., docker health check)

0.7.1

  • Fixed handling of NaN and Infinity in inputs for bounds and center (#58)

0.7.0

  • Added support for padding image bounds
  • Handle missing remote assets correctly (#49)
  • Added support for image sources (#52)
  • Added request logging (#54)

0.6.2

  • Fix bad handling of root path (#43)

0.6.1

  • Docker: fix missing /app/tiles directory if user does not bind in a tiles directory (resolves #40)

0.6.0

  • upgraded mapbox-gl-native to 5.0.0 (#35). NOTE: https://github.com/mapbox/mapbox-gl-native/blob/master/platform/node/CHANGELOG.md#500.
  • warn rather than fail on missing tiles

O.5.0

  • upgraded Docker to NodeJS 10
  • reduced size of Docker image and simplified Xvfb management
  • added support for pitch and bearing options during rendering (#31)

0.4.0

  • rendering now uses floating point zoom levels when bounds are provided as inputs
  • downgraded supported version of Node to 8, due to occasional segfaults: https://github.com/mapbox/mapbox-gl-native/issues/12252

Prior to 0.3.1, there was a significant bug in rendering layers with transparency (#25).

Credits

This project was made possible based on support from the South Atlantic Landscape Conservation Cooperative ([] and the Paulson Institute ([]

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Brendan Ward
https://github.com/consbio/mbgl-renderer/commits?author=brendan-ward https://github.com/consbio/mbgl-renderer/commits?author=brendan-ward https://github.com/consbio/mbgl-renderer/issues?q=author%3Abrendan-ward 📝 https://github.com/consbio/mbgl-renderer/pulls?q=is%3Apr+reviewed-by%3Abrendan-ward 🤔
https://github.com/nikmolnar
https://github.com/consbio/mbgl-renderer/commits?author=nikmolnar https://github.com/consbio/mbgl-renderer/issues?q=author%3Anikmolnar 🤔
https://github.com/ka7eh
https://github.com/consbio/mbgl-renderer/issues?q=author%3Aka7eh 🤔
https://github.com/bertrandmd
https://github.com/consbio/mbgl-renderer/commits?author=bertrandmd
https://github.com/korpd
https://github.com/consbio/mbgl-renderer/commits?author=korpd
https://github.com/kjkurtz
https://github.com/consbio/mbgl-renderer/commits?author=kjkurtz

Norman Rzepka
https://github.com/consbio/mbgl-renderer/commits?author=normanrz
https://github.com/submarcos
https://github.com/consbio/mbgl-renderer/issues?q=author%3Asubmarcos

Jez Nicholson
https://github.com/consbio/mbgl-renderer/issues?q=author%3Ajnicho02 🤔
https://github.com/bob-gray
https://github.com/consbio/mbgl-renderer/issues?q=author%3Abob-gray
https://github.com/abraztsov
https://github.com/consbio/mbgl-renderer/issues?q=author%3Aabraztsov
https://github.com/LePetitTim
https://github.com/consbio/mbgl-renderer/issues?q=author%3ALePetitTim

felix
https://github.com/consbio/mbgl-renderer/commits?author=Stunkymonkey

This project follows the https://github.com/all-contributors/all-contributors specification. Contributions of any kind welcome!

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 mbgl-renderer 镜像标签

docker pull docker.xuanyuan.run/consbio/mbgl-renderer:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull consbio/mbgl-renderer:<标签>

更多 mbgl-renderer 镜像推荐

grafana/grafana-image-renderer logo

grafana/grafana-image-renderer

grafana
Grafana 远程图像渲染器镜像,通过无头 Chrome 将 Grafana 面板和仪表板渲染为 PNG 格式,支持集成到报表生成、自动化流程等场景。
32 次收藏5亿+ 次下载
2 天前更新
rancher/mirrored-grafana-grafana-image-renderer logo

rancher/mirrored-grafana-grafana-image-renderer

rancher
暂无描述
10万+ 次下载
19 天前更新
rancher/grafana-grafana-image-renderer logo

rancher/grafana-grafana-image-renderer

rancher
暂无描述
2.6千+ 次下载
1 年前更新
mbgl/android-ndk-r21e logo

mbgl/android-ndk-r21e

mbgl
暂无描述
10万+ 次下载
3 年前更新
mbgl/android-ndk-r22-jdk17 logo

mbgl/android-ndk-r22-jdk17

mbgl
暂无描述
10万+ 次下载
1 年前更新
mbgl/android-ndk-r22 logo

mbgl/android-ndk-r22

mbgl
暂无描述
10万+ 次下载
2 年前更新

查看更多 mbgl-renderer 相关镜像

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

Harbor 镜像源配置

Harbor Proxy Repository 对接专属域名

Portainer 镜像源配置

Portainer Registries 加速拉取

Nexus 镜像源配置

Nexus3 Docker Proxy 内网缓存

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

配置了专属域名后,docker search 为什么会报错?

docker search 限制

Docker Hub 上有的镜像,为什么在轩辕镜像网站搜不到?

站内搜不到镜像

机器不能直连外网时,怎么用 docker save / load 迁镜像?

离线 save/load

docker pull 拉插件报错(plugin v1+json)怎么办?

插件要用 plugin install

WSL 里 Docker 拉镜像特别慢,怎么排查和优化?

WSL 拉取慢

轩辕镜像安全吗?如何用 digest 校验镜像没被篡改?

安全与 digest

第一次用轩辕镜像拉 Docker 镜像,要怎么登录和配置?

新手拉取配置

轩辕镜像合规吗?轩辕镜像的合规是怎么做的?

镜像合规机制

轩辕镜像支持 docker push 上传本地镜像吗?

不支持 push

错误码与失败问题

docker pull 提示 manifest unknown 怎么办?

manifest unknown

docker pull 提示 no matching manifest 怎么办?

no matching manifest(架构)

镜像已拉取完成,却提示 invalid tar header 或 failed to register layer 怎么办?

invalid tar header(解压)

Docker pull 时 HTTPS / TLS 证书验证失败怎么办?

TLS 证书失败

Docker pull 时 DNS 解析超时或连不上仓库怎么办?

DNS 超时

docker 无法连接轩辕镜像域名怎么办?

域名连通性排查

Docker 拉取出现 410 Gone 怎么办?

410 Gone 排查

出现 402 或「流量用尽」提示怎么办?

402 与流量用尽

Docker 拉取提示 UNAUTHORIZED(401)怎么办?

401 认证失败

遇到 429 Too Many Requests(请求太频繁)怎么办?

429 限流

docker login 提示 Cannot autolaunch D-Bus,还算登录成功吗?

D-Bus 凭证提示

为什么会出现「单层超过 20GB」或 413,无法加速拉取?

413 与超大单层

账号 / 计费 / 权限

轩辕镜像免费版和专业版有什么区别?

免费版与专业版区别

轩辕镜像支持哪些 Docker 镜像仓库?

支持的镜像仓库

镜像拉取失败还会不会扣流量?

失败是否计费

麒麟 V10 / 统信 UOS 提示 KYSEC 权限不够怎么办?

KYSEC 拦截脚本

如何在轩辕镜像申请开具发票?

申请开票

怎么修改轩辕镜像的网站登录和仓库登录密码?

修改登录密码

如何注销轩辕镜像账户?要注意什么?

注销账户

配置与原理类

写了 registry-mirrors,为什么还是走官方或仍然报错?

mirrors 不生效

怎么用 docker tag 去掉镜像名里的轩辕域名前缀?

去掉域名前缀

如何拉取指定 CPU 架构的镜像(如 ARM64、AMD64)?

指定架构拉取

用轩辕镜像拉镜像时快时慢,常见原因有哪些?

拉取速度原因

为什么拉取镜像的 :latest 标签,拿到的往往不是「最新」镜像?

latest 与「最新」

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
consbio/mbgl-renderer
博客Docker 镜像公告与技术博客
热门查看热门 Docker 镜像推荐
安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单。官方公众号:源码跳动。官方技术交流群:51517718。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单。官方公众号:源码跳动。官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
商务合作:点击复制邮箱
©2024-2026 源码跳动
商务合作:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.