Skip to content

Commit

Permalink
Docs: 更新 mapbox 文档
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Sep 23, 2024
1 parent 33a26d7 commit c7cae20
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 11 deletions.
4 changes: 2 additions & 2 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,10 @@ disableThemeInject = false
accessToken = "pk.eyJ1IjoiZGlsbG9uenEiLCJhIjoiY2s2czd2M2x3MDA0NjNmcGxmcjVrZmc2cyJ9.aSjv2BNuZUfARvxRYjSVZQ"
# style for the light theme
# 浅色主题的地图样式
lightStyle = "mapbox://styles/mapbox/light-v10?optimize=true"
lightStyle = "mapbox://styles/mapbox/light-v11?optimize=true"
# style for the dark theme
# 深色主题的地图样式
darkStyle = "mapbox://styles/mapbox/dark-v10?optimize=true"
darkStyle = "mapbox://styles/mapbox/dark-v11?optimize=true"
# whether to add NavigationControl (https://docs.mapbox.com/mapbox-gl-js/api/#navigationcontrol)
# 是否添加 导航控制 (https://docs.mapbox.com/mapbox-gl-js/api/#navigationcontrol)
navigation = true
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: The mapbox shortcode supports interactive maps in Hugo with Mapbox
library.
resources:
- name: featured-image
src: featured-image.jpg
src: featured-image.webp
tags:
- Shortcodes
- Content
Expand All @@ -24,6 +24,8 @@ The `mapbox` shortcode supports interactive maps in Hugo with [Mapbox GL JS][map

<!--more-->

## Parameters

[Mapbox GL JS][mapbox] is a JavaScript library that uses WebGL to render interactive maps from [vector tiles][vector-tiles] and [Mapbox styles][style-spec].

The `mapbox` shortcode has the following named parameters to use Mapbox GL JS:
Expand Down Expand Up @@ -52,6 +54,10 @@ The `mapbox` shortcode has the following named parameters to use Mapbox GL JS:

Style for the dark theme, default value is the value set in the [front matter][front-matter] or the [theme configuration][theme-config].

- **markers** _[optional]_ (**seventh** positional parameter) {{< version 0.3.11 >}}

An array of map markers, each element in the array is an object that contains three properties: `lng`, `lat`, and `description`.

- **navigation** _[optional]_

Whether to add [NavigationControl][navigationcontrol], default value is the value set in the [front matter][front-matter] or the [theme configuration][theme-config].
Expand All @@ -76,6 +82,8 @@ The `mapbox` shortcode has the following named parameters to use Mapbox GL JS:

Height of the map, default value is `20rem`.

## Simple Example

Example simple `mapbox` input:

```markdown
Expand All @@ -88,6 +96,8 @@ The rendered output looks like this:

{{< mapbox 113.953277 22.559102 11 >}}

## Custom Style Example

Example `mapbox` input with the custom style:

```markdown
Expand All @@ -100,6 +110,26 @@ The rendered output looks like this:

{{< mapbox -122.252 37.453 10 false "mapbox://styles/mapbox/navigation-preview-day-v4?optimize=true" "mapbox://styles/mapbox/navigation-preview-night-v4?optimize=true" >}}

## Multiple Markers Example

Example `mapbox` input with multiple markers:

```markdown
{{</* mapbox
lng=113.953277
lat=22.559102
markers="[{\"lng\": 113.81841, \"lat\": 22.637524, \"description\": \"Bao'an International Airport\"},{\"lng\": 113.953386, \"lat\": 22.559052, \"description\": \"清华信息港\"},{\"lng\": 114.035746,\"lat\": 22.615667, \"description\": \"Shenzhen North railway station\"}]"
*/>}}
```

{{< mapbox
lng=113.953277
lat=22.559102
markers="[{\"lng\": 113.81841, \"lat\": 22.637524, \"description\": \"Bao'an International Airport\"},{\"lng\": 113.953386, \"lat\": 22.559052, \"description\": \"Marker 2\"},{\"lng\": 114.035746,\"lat\": 22.615667, \"description\": \"Shenzhen North railway station\"}]"
>}}
<!-- link reference definition -->
<!-- markdownlint-disable-file MD052 -->
[mapbox]: https://docs.mapbox.com/mapbox-gl-js
[vector-tiles]: https://docs.mapbox.com/help/glossary/vector-tiles/
[style-spec]: https://docs.mapbox.com/mapbox-gl-js/style-spec/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1400,9 +1400,9 @@ c4u
# access token of Mapbox GL JS
accessToken = ""
# style for the light theme
lightStyle = "mapbox://styles/mapbox/light-v9"
lightStyle = "mapbox://styles/mapbox/light-v11"
# style for the dark theme
darkStyle = "mapbox://styles/mapbox/dark-v9"
darkStyle = "mapbox://styles/mapbox/dark-v11"
# whether to add {{< link "https://docs.mapbox.com/mapbox-gl-js/api#navigationcontrol" NavigationControl >}}
navigation = true
# whether to add {{< link "https://docs.mapbox.com/mapbox-gl-js/api#geolocatecontrol" GeolocateControl >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ author:
description: mapbox shortcode 使用 Mapbox GL JS 库提供互动式地图的功能。
resources:
- name: featured-image
src: featured-image.jpg
src: featured-image.webp
tags:
- Shortcodes
- Content
Expand All @@ -26,6 +26,8 @@ mapbox:

<!--more-->

## 参数

[Mapbox GL JS][mapbox] 是一个 JavaScript 库,它使用 WebGL, 以 [vector tiles][vector-tiles][Mapbox styles][style-spec] 为来源,将它们渲染成互动式地图。

`mapbox` shortcode 有以下命名参数来使用 Mapbox GL JS:
Expand Down Expand Up @@ -54,6 +56,10 @@ mapbox:

深色主题的地图样式,默认值是 [Front matter][front-matter] 或者 [主题配置][theme-config] 中设置的值。

- **markers** _[可选]_**第七个**位置参数){{< version 0.3.11 >}}

地图标记的数组,数组元素是对象,对象包含 `lng``lat``description` 三个属性。

- **navigation** _[可选]_

是否添加 [NavigationControl][navigationcontrol], 默认值是 [Front matter][front-matter] 或者 [主题配置][theme-config] 中设置的值。
Expand All @@ -78,6 +84,8 @@ mapbox:

地图的高度,默认值是 `20rem`

## 简单示例

一个简单的 `mapbox` 示例:

```markdown
Expand All @@ -90,6 +98,8 @@ mapbox:

{{< mapbox 113.953277 22.559102 11 >}}

## 自定义样式

一个带有自定义样式的 `mapbox` 示例:

```markdown
Expand All @@ -102,6 +112,26 @@ mapbox:

{{< mapbox -122.252 37.453 10 false "mapbox://styles/mapbox/streets-zh-v1?optimize=true" >}}

## 多标记示例

一个带有多个标记的 `mapbox` 示例:

```markdown
{{</* mapbox
lng=113.953277
lat=22.559102
markers="[{\"lng\": 113.81841, \"lat\": 22.637524, \"description\": \"宝安国际机场\"},{\"lng\": 113.953386, \"lat\": 22.559052, \"description\": \"标记 2\"},{\"lng\": 114.035746,\"lat\": 22.615667, \"description\": \"深圳北站\"}]"
*/>}}
```

{{< mapbox
lng=113.953277
lat=22.559102
markers="[{\"lng\": 113.81841, \"lat\": 22.637524, \"description\": \"宝安国际机场\"},{\"lng\": 113.953386, \"lat\": 22.559052, \"description\": \"标记 2\"},{\"lng\": 114.035746,\"lat\": 22.615667, \"description\": \"深圳北站\"}]"
>}}
<!-- link reference definition -->
<!-- markdownlint-disable-file MD052 -->
[mapbox]: https://docs.mapbox.com/mapbox-gl-js
[vector-tiles]: https://docs.mapbox.com/help/glossary/vector-tiles/
[style-spec]: https://docs.mapbox.com/mapbox-gl-js/style-spec/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1391,9 +1391,9 @@ c4u
# Mapbox GL JS 的 access token
accessToken = ""
# 浅色主题的地图样式
lightStyle = "mapbox://styles/mapbox/light-v9"
lightStyle = "mapbox://styles/mapbox/light-v11"
# 深色主题的地图样式
darkStyle = "mapbox://styles/mapbox/dark-v9"
darkStyle = "mapbox://styles/mapbox/dark-v11"
# 是否添加 {{< link "https://docs.mapbox.com/mapbox-gl-js/api#navigationcontrol" NavigationControl >}}
navigation = true
# 是否添加 {{< link "https://docs.mapbox.com/mapbox-gl-js/api#geolocatecontrol" GeolocateControl >}}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/hugo-fixit/docs
go 1.20

require (
github.com/hugo-fixit/FixIt v0.3.12-0.20240910094900-fad3c988deab // indirect
github.com/hugo-fixit/FixIt v0.3.12-0.20240923082518-fabe057f610d // indirect
github.com/hugo-fixit/component-projects v1.1.3 // indirect
github.com/hugo-fixit/shortcode-caniuse v1.1.3 // indirect
github.com/hugo-fixit/shortcode-rewards v1.0.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/hugo-fixit/FixIt v0.3.12-0.20240910094900-fad3c988deab h1:FGIq9PptHv7bCWjjFXgahNF/cNZMmCof94UykwQbpcE=
github.com/hugo-fixit/FixIt v0.3.12-0.20240910094900-fad3c988deab/go.mod h1:3XIRedrqakO7/a4ZnhE46haMRF8HgsT0N0B5j5D2iRU=
github.com/hugo-fixit/FixIt v0.3.12-0.20240923082518-fabe057f610d h1:QOK9d+fqpr57p5SoI2ClZbhoHb+Jw6sPX6wV7oRl97Y=
github.com/hugo-fixit/FixIt v0.3.12-0.20240923082518-fabe057f610d/go.mod h1:3XIRedrqakO7/a4ZnhE46haMRF8HgsT0N0B5j5D2iRU=
github.com/hugo-fixit/component-projects v1.1.3 h1:iK6q07CpFsnnJGh8q2stVjv6Lr77dTM9o+P7LGDEYmE=
github.com/hugo-fixit/component-projects v1.1.3/go.mod h1:nXW0R37REwpfwUD1I4RtB5QW71vw66nRyB9uEpYxr+c=
github.com/hugo-fixit/shortcode-caniuse v1.1.3 h1:U1YBJz5SI/d1BBQhHcD0eVgJdCcpzK2usSizPiu+a4w=
Expand Down

0 comments on commit c7cae20

Please sign in to comment.