Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,31 @@

<!-- preview -->

*This API is available for [Commercial and Enterprise](https://www.mapbox.com/pricing/) plans.*

The Mapbox Analytics API returns API usage for services by resource. For example, it can calculate the number of geocoding requests made in a week with a specific access token.
*这份API适用于 [ Commercial and Enterprise ](https://www.mapbox.com/pricing/) 计划。*

此Mapbox Analytics API 将按资源返回服务的API使用情况。例如,它可以通过一个特定的访问token来计算过去一周内发起的地理编码请求的次数。
```python
from mapbox import Analytics
```

### Retrieve analytics

Returns the request counts per day for given resource and period.
根据给出的资源和时段返回按天统计的某一请求发起的次数。

* If the `{resourceType}` is `tokens`, the `{id}` is the complete token.
* If the `{resourceType}` is `styles`, the `{id}` is the Style ID. Not to be confused with the Style _URL_, the id is the alphanumeric segment at the end of the style: the Style URL `mapbox://styles/user/cimdoca6f00` contains the Style ID `cimdoca6f00`, so the analytics request would have the path `/analytics/v1/styles/user/cimdoca6f00`.
* If the `{resourceType}` is `tilesets`, the `{id}` is a Map ID.
* 如果 `{resourceType}` `tokens`, `{id}` 是完整的token。
* 如果 `{resourceType}` `styles`, `{id}` 是Style ID。注意不要与 Style _URL_ 混淆,此 id 是样式末尾的字母数字部分: 此 Style URL `mapbox://styles/user/cimdoca6f00` 包含Style ID `cimdoca6f00`, 所以此分析请求的路径则为 `/analytics/v1/styles/user/cimdoca6f00`
* 如果 `{resourceType}` `tilesets`, `{id}` 是一个 Map ID.

```endpoint
GET /analytics/v1/{resourceType}/{username}/{id}?period={period} analytics:read
```

URL Parameter | Description
URL 参数 | 描述
--- | ---
`resourceType` | The resource being requested. Valid resource types are `accounts`, `tokens`, `tilesets` or `styles`.
`username` | The username for the account that owns the resource.
`id` <br /> (optional) | The id for the resource. In the case of `accounts` this isn't required.
`period` <br /> (optional) | 2 comma separated dates as [ISO formatted strings](#dates). The first date must be earlier than the second. The period is inclusive of dates provided. Defaults to last 90 days if not provided. The maximum period is 1 year. If the provided dates are more than 1 year apart, an error will be returned.
`resourceType` | 被请求的资源类型。可用的类型有 `accounts` `tokens` `tilesets` `styles`
`username` | 拥有此资源的账户用户名。
`id` <br /> (可选) | 此资源的id。如果类型为 `accounts` 则此项不必需。
`period` <br /> (可选) | 由两个逗号分割的格式为 [ISO formatted strings](#dates)的日期。 第一个日期必须早于第二个日期。区间包括给出的日期。如果未提供此项,则默认为过去的90天。最长区间为1年。如果提供的两个日期相隔超过1年,则会返回一个错误。


#### Example Request
Expand Down Expand Up @@ -76,21 +75,21 @@ response = analytics.analytics('accounts', '{username}')
}
```

Responses include arrays of request counts per service.
包含每项服务各请求数目数组的响应。

Property | Description
属性 | 描述
--- | ---
`timestamps` | an array of dates as ISO formatted strings for each day included in the response.
`period` | a 2 element array with start and end dates as ISO formatted strings for the response period.
`services` | an object with a key per service the value of which is an array of request counts per day in the same sequence as `timestamps`.
`timestamps` | 包含在此响应中的 ISO formatted strings 类型的日期数组。
`period` | 一个包含两个元素的数组,分别为此响应区间的 ISO formatted strings 类型的开始与结束日期。
`services` | 每一项服务对应的一个带密钥对象。其值为记录每天请求数量的一个数组,顺序与 `timestamps` 中的时序一致。

Only services applicable to the given resource are returned in the response.
只有适用于给出的资源的服务会在响应中被返回。

Resource type | Services returned in response
资源类型 | 在响应中被返回的服务
--- | ---
`accounts` | `mapview` `static` `tile` `directions` `geocode`
`tokens` | `mapview` `static` `tile` `directions` `geocode`
`tilesets` | `mapview` `static` `tile`
`styles` | `mapview` `static` `tile`

For the `styles` resource type, Static & Tile services refer to the [Static API](#static). For `tilesets`, Static & Tile services refer to the [Static (Classic)](#static-classic) and [Maps → Tiles](#retrieve-tiles) APIs.
对于 `styles` 资源类型, Static Tile 服务请参考 [Static API](#static)。 对于 `tilesets`资源类型, Static Tile 服务请参考 [Static (Classic)](#static-classic) [Maps → Tiles](#retrieve-tiles) APIs
48 changes: 24 additions & 24 deletions fonts.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
## Fonts
## 字体

The Mapbox Fonts API accepts fonts as raw binary data, allows those fonts to be deleted, and generates encoded letters for map renderers. Two types of fonts are supported: TrueType fonts, usually with `.ttf` file extensions, and OpenType fonts, with `.otf` extensions.
Mapbox字体API接受形式为原始二进制码的字体,允许删除这些字体,并且为地图渲染器生成代码。它支持两种类型的字体:TrueType字体,文件后缀名通常为`.ttf`,以及OpenType字体,后缀名为`.otf`

Fonts are managed on a per-account basis. Styles can use any font from the same account.
字体按账户来管理。同一账户可以在样式中使用任何字体。

**Restrictions and limits**
**限制和约束**

- Fonts must be smaller than 30MB.
- Accounts are limited to 100 fonts.
- 字体必须小于30MB。
- 每个账户最多使用100个字体。

### Retrieve font glyph ranges
### 检索字体字形范围

```endpoint
GET /fonts/v1/{username}/{font}/{start}-{end}.pbf fonts:read
```

While glyph ranges are usually not of interest unless you're building a map renderer, this is the endpoint you can use to access them.
虽然字形范围一般不被关注,除非你正在建立一个地图渲染器,但这是访问它们的端点。

Font glyph ranges are protocol buffer-encoded signed distance fields. They can be used to show fonts at a variety of scales and rotations. One glyph is used at all scales.
字体字形范围是协议缓冲编码的带符号距离字段。它们可用于显示各种比例和旋转的字体。一个字形支持所有比例。

URL Parameter | Description
URL 参数 | 描述
--- | ---
`username` | The username of the account to which the font belongs.
`font` | The name of the font. This endpoint supports queries with multiple comma-separated font names.
`start` | A multiple of `256` between `0` and `65280`.
`end` | The number indicated by `start`, plus `255`.
`username` | 该字体所属账户的用户名。
`font` | 字体的名称。此端点支持查询多个字体名称,名称间用逗号隔开。
`start` | `0`到`65280`之间`256`的倍数。
`end` | `start`显示的数字加上`255`

**Response body**
**响应主体**

A successful request will return `HTTP 200 Success`. The response body will be a buffer of the glyphs with `Content-Type: application/x-protobuf`.
一个成功的请求将会返回`HTTP 200 Success`。响应主体将会是字形的一个缓存,字形带有`Content-Type: application/x-protobuf`

#### Example request
#### 示例请求

```curl
# Query contains 2 comma-separated font names
# 查询包含两个由逗号分隔的字体名
curl "https://api.mapbox.com/fonts/v1/examples/DIN Offc Pro Medium,Arial Unicode MS Regular/0-255?access_token={your_access_token}"
```

Expand All @@ -51,26 +51,26 @@ stylesClient
```

```python
# This API cannot be accessed with the Python SDK
# 无法使用Python SDK访问此API
```

```bash
This API cannot be accessed with Mapbox CLI
无法使用Mapbox CLI访问此API
```

```java
// This API cannot be accessed with the Mapbox Java SDK
// 无法使用Mapbox Java SDK访问此API
```

```objc
// This API cannot be accessed with the Mapbox Objective-C libraries
// 无法使用Mapbox Objective-C 库访问此API
```

```swift
// This API cannot be accessed with the Mapbox Swift libraries
// 无法使用Mapbox Swift库访问此API
```


#### Response
#### 响应

> `HTTP 200 Success`
Loading