通过


你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

@azure-rest/maps-render package

接口

CircularPath

指定循环路径。

CircularPathOptions

修改循环路径样式的选项。

CopyrightCaptionOutput

此对象从成功的版权调用返回

CopyrightOutput

此对象是从成功的版权请求返回的

ErrorAdditionalInfoOutput

资源管理错误附加信息。

ErrorDetailOutput

错误详细信息。

ErrorResponseOutput

所有 Azure 资源管理器 API 的常见错误响应,以返回失败操作的错误详细信息。 (这也遵循 OData 错误响应格式)。

GetCopyrightCaption
GetCopyrightForTile
GetCopyrightForWorld
GetCopyrightFromBoundingBox
GetMapAttribution
GetMapStateTile
GetMapStaticImage
GetMapTile
GetMapTileset
MapAttributionOutput

图块集所请求部分的版权归属。

MapTilesetOutput

TileJSON 格式的图块集的元数据。

MapsRenderClientOptions

客户端的可选参数

Pin

指定图钉的位置和标签文本的方式。

PinOptions

默认/无图像样式的固定选项。

PinSet
PolygonalPath

指定多边形路径。

PolygonalPathOptions

修改多边形路径样式的选项。

RegionCopyrightsCountryOutput

Country 属性

RegionCopyrightsOutput
RenderGetCopyrightCaption200Response

Get Copyright Caption API 是一个 HTTP GET 请求,旨在提供版权信息,用于从呈现服务请求的磁贴。 除了整个地图的基本版权外,它还可以为一些国家/地区提供特定版权组。

作为地图请求版权的替代方法,它还可以返回用于在地图上显示提供程序信息的标题。

RenderGetCopyrightCaptionDefaultResponse

Get Copyright Caption API 是一个 HTTP GET 请求,旨在提供版权信息,用于从呈现服务请求的磁贴。 除了整个地图的基本版权外,它还可以为一些国家/地区提供特定版权组。

作为地图请求版权的替代方法,它还可以返回用于在地图上显示提供程序信息的标题。

RenderGetCopyrightForTile200Response

若要获取特定磁贴的版权信息,请求应指定磁贴的缩放级别和 x 和 y 坐标。 有关详细信息,请参阅 缩放级别和磁贴网格

版权 API 旨在为呈现服务提供版权信息。 除了整个地图的基本版权外,API 还为一些国家/地区提供特定版权组。

RenderGetCopyrightForTileDefaultResponse

若要获取特定磁贴的版权信息,请求应指定磁贴的缩放级别和 x 和 y 坐标。 有关详细信息,请参阅 缩放级别和磁贴网格

版权 API 旨在为呈现服务提供版权信息。 除了整个地图的基本版权外,API 还为一些国家/地区提供特定版权组。

RenderGetCopyrightForTileQueryParam
RenderGetCopyrightForTileQueryParamProperties
RenderGetCopyrightForWorld200Response

返回世界的版权信息。 若要获取全世界的默认版权信息,请不要指定磁贴或边界框。

版权 API 旨在为呈现服务提供版权信息。 除了整个地图的基本版权外,API 还为一些国家/地区提供特定版权组。

RenderGetCopyrightForWorldDefaultResponse

返回世界的版权信息。 若要获取全世界的默认版权信息,请不要指定磁贴或边界框。

版权 API 旨在为呈现服务提供版权信息。 除了整个地图的基本版权外,API 还为一些国家/地区提供特定版权组。

RenderGetCopyrightForWorldQueryParam
RenderGetCopyrightForWorldQueryParamProperties
RenderGetCopyrightFromBoundingBox200Response

返回给定边界框的版权信息。 边界框请求应指定最小和最大经度和纬度 (EPSG-3857) 坐标

RenderGetCopyrightFromBoundingBoxDefaultResponse

返回给定边界框的版权信息。 边界框请求应指定最小和最大经度和纬度 (EPSG-3857) 坐标

RenderGetCopyrightFromBoundingBoxQueryParam
RenderGetCopyrightFromBoundingBoxQueryParamProperties
RenderGetMapAttribution200Response

Get Map Attribution API 允许用户请求图块集部分的地图版权归属信息。

RenderGetMapAttributionDefaultResponse

Get Map Attribution API 允许用户请求图块集部分的地图版权归属信息。

RenderGetMapAttributionQueryParam
RenderGetMapAttributionQueryParamProperties
RenderGetMapStateTile200Headers
RenderGetMapStateTile200Response

提取矢量格式的状态磁贴通常要集成到地图控件或 SDK 的室内地图模块中。 用户启用动态样式设置后,地图控件将调用此 API。 有关详细信息,请参阅 缩放级别和磁贴网格

RenderGetMapStateTileDefaultResponse

提取矢量格式的状态磁贴通常要集成到地图控件或 SDK 的室内地图模块中。 用户启用动态样式设置后,地图控件将调用此 API。 有关详细信息,请参阅 缩放级别和磁贴网格

RenderGetMapStateTileQueryParam
RenderGetMapStateTileQueryParamProperties
RenderGetMapStaticImage200Headers
RenderGetMapStaticImage200Response

此呈现 API 生成用户定义的区域的静态光栅化地图视图。 它适用于轻型 Web 应用程序,当所需的用户体验不需要交互式地图控件或带宽受限时。 此 API 还可用于在浏览器外部、后端服务、报表生成或桌面应用程序中嵌入映射。

此 API 包括基本数据可视化的参数:

  • 多个样式中标记的图钉。
  • 呈现圆形、路径和多边形几何图形类型。

有关详细信息和详细示例,请参阅 光栅地图上呈现自定义数据。

bbox 参数的尺寸受约束,具体取决于缩放级别。 这可确保生成的图像具有适当的详细信息级别。

缩放级别 Min Lon Range 最大 Lon 范围 Min Lat 范围 最大 Lat 范围
0 56.25 360.0 30.1105585173 180.0
1 28.125 360.0 14.87468995 180.0
2 14.063 351.5625 7.4130741851 137.9576312246
3 7.03125 175.78125 3.7034501005 73.6354071932
4 3.515625 87.890625 1.8513375155 35.4776115315
5 1.7578125 43.9453125 0.925620264 17.4589959239
6 0.87890625 21.97265625 0.4628040687 8.6907788223
7 0.439453125 10.986328125 0.2314012764 4.3404320789
8 0.2197265625 5.4931640625 0.1157005434 2.1695927024
9 0.1098632812 2.7465820312 0.0578502599 1.0847183194
10 0.0549316406 1.3732910156 0.0289251285 0.5423494021
11 0.0274658203 0.6866455078 0.014462564 0.2711734813
12 0.0137329102 0.3433227539 0.007231282 0.1355865882
13 0.0068664551 0.171661377 0.003615641 0.067793275
14 0.0034332275 0.0858306885 0.0018078205 0.0338966351
15 0.0017166138 0.0429153442 0.0009039102 0.0169483173
16 0.0008583069 0.0214576721 0.0004519551 0.0084741586
17 0.0004291534 0.0107288361 0.0002259776 0.0042370793
18 0.0002145767 0.005364418 0.0001129888 0.0021185396
19 0.0001072884 0.002682209 5.64944E-05 0.0010592698
20 5.36442E-05 0.0013411045 2.82472E-05 0.0005296349

注意:必须向 API 提供 中心bbox 参数。

RenderGetMapStaticImageDefaultResponse

此呈现 API 生成用户定义的区域的静态光栅化地图视图。 它适用于轻型 Web 应用程序,当所需的用户体验不需要交互式地图控件或带宽受限时。 此 API 还可用于在浏览器外部、后端服务、报表生成或桌面应用程序中嵌入映射。

此 API 包括基本数据可视化的参数:

  • 多个样式中标记的图钉。
  • 呈现圆形、路径和多边形几何图形类型。

有关详细信息和详细示例,请参阅 光栅地图上呈现自定义数据。

bbox 参数的尺寸受约束,具体取决于缩放级别。 这可确保生成的图像具有适当的详细信息级别。

缩放级别 Min Lon Range 最大 Lon 范围 Min Lat 范围 最大 Lat 范围
0 56.25 360.0 30.1105585173 180.0
1 28.125 360.0 14.87468995 180.0
2 14.063 351.5625 7.4130741851 137.9576312246
3 7.03125 175.78125 3.7034501005 73.6354071932
4 3.515625 87.890625 1.8513375155 35.4776115315
5 1.7578125 43.9453125 0.925620264 17.4589959239
6 0.87890625 21.97265625 0.4628040687 8.6907788223
7 0.439453125 10.986328125 0.2314012764 4.3404320789
8 0.2197265625 5.4931640625 0.1157005434 2.1695927024
9 0.1098632812 2.7465820312 0.0578502599 1.0847183194
10 0.0549316406 1.3732910156 0.0289251285 0.5423494021
11 0.0274658203 0.6866455078 0.014462564 0.2711734813
12 0.0137329102 0.3433227539 0.007231282 0.1355865882
13 0.0068664551 0.171661377 0.003615641 0.067793275
14 0.0034332275 0.0858306885 0.0018078205 0.0338966351
15 0.0017166138 0.0429153442 0.0009039102 0.0169483173
16 0.0008583069 0.0214576721 0.0004519551 0.0084741586
17 0.0004291534 0.0107288361 0.0002259776 0.0042370793
18 0.0002145767 0.005364418 0.0001129888 0.0021185396
19 0.0001072884 0.002682209 5.64944E-05 0.0010592698
20 5.36442E-05 0.0013411045 2.82472E-05 0.0005296349

注意:必须向 API 提供 中心bbox 参数。

RenderGetMapStaticImageQueryParam
RenderGetMapStaticImageQueryParamProperties
RenderGetMapTile200Headers
RenderGetMapTile200Response

HTTP GET 请求中的 Get Map Tiles API,允许用户请求矢量或光栅格式的地图图块通常集成到地图控件或 SDK 中。 可以请求的一些示例磁贴是 Azure Maps 道路图块、实时天气雷达图块或使用 azure Maps Creator创建的地图图块。 默认情况下,Azure Maps 为其 Web 地图控件(Web SDK)使用矢量图块,Android SDK

RenderGetMapTileDefaultResponse

HTTP GET 请求中的 Get Map Tiles API,允许用户请求矢量或光栅格式的地图图块通常集成到地图控件或 SDK 中。 可以请求的一些示例磁贴是 Azure Maps 道路图块、实时天气雷达图块或使用 azure Maps Creator创建的地图图块。 默认情况下,Azure Maps 为其 Web 地图控件(Web SDK)使用矢量图块,Android SDK

RenderGetMapTileQueryParam
RenderGetMapTileQueryParamProperties
RenderGetMapTileset200Response

获取地图图块集 API 允许用户请求图块集的元数据。

RenderGetMapTilesetDefaultResponse

获取地图图块集 API 允许用户请求图块集的元数据。

RenderGetMapTilesetQueryParam
RenderGetMapTilesetQueryParamProperties
Routes

类型别名

MapsRenderClient
RenderGetCopyrightCaptionParameters
RenderGetCopyrightForTileParameters
RenderGetCopyrightForWorldParameters
RenderGetCopyrightFromBoundingBoxParameters
RenderGetMapAttributionParameters
RenderGetMapStateTileParameters
RenderGetMapStaticImageParameters
RenderGetMapTileParameters
RenderGetMapTilesetParameters

函数

createPathQuery((PolygonalPath | CircularPath)[])

获取地图静态图像 请求创建路径查询字符串。

示例

import { DefaultAzureCredential } from "@azure/identity";
import MapsRender, { CircularPath, PolygonalPath, createPathQuery } from "@azure-rest/maps-render";
import { createWriteStream } from "node:fs";

const credential = new DefaultAzureCredential();
const client = MapsRender(credential, "<maps-account-client-id>");

const circularPath: CircularPath = {
  center: [52.4559, 13.228],
  radiusInMeters: 10000,
  options: {
    lineColor: "000000",
    lineOpacity: 0.9,
    lineWidthInPixels: 2,
  },
};

const linearPath: PolygonalPath = {
  coordinates: [
    [52.577, 13.35],
    [52.6, 13.2988],
    [52.32, 13.2988],
  ],
  options: {
    lineColor: "000000",
    lineOpacity: 0.9,
    lineWidthInPixels: 2,
  },
};

const polygonPath: PolygonalPath = {
  coordinates: [
    [52.577, 13.35],
    [52.6, 13.2988],
    [52.32, 13.2988],
    [52.577, 13.35],
  ],
  options: {
    lineColor: "000000",
    lineOpacity: 0.9,
    lineWidthInPixels: 2,
    fillColor: "FFFFFF",
    fillOpacity: 0.8,
  },
};

const path = createPathQuery([circularPath, linearPath, polygonPath]);
// Send the request
const response = await client
  .path("/map/static")
  .get({
    queryParameters: {
      bbox: [13.228, 52.4559, 13.5794, 52.629],
      path,
    },
  })
  .asNodeStream();

// Handle the error.
if (!response.body) {
  throw Error("No response body");
}

response.body.pipe(createWriteStream("path.png"));
createPinsQuery(PinSet[])

获取地图静态图像创建固定查询字符串

示例

import { DefaultAzureCredential } from "@azure/identity";
import MapsRender, { PinSet, createPinsQuery } from "@azure-rest/maps-render";
import { createWriteStream } from "node:fs";

const credential = new DefaultAzureCredential();
const client = MapsRender(credential, "<maps-account-client-id>");

const pins: PinSet[] = [
  {
    pins: [
      { coordinate: [52.577, 13.35], label: "Label start" },
      { coordinate: [52.6, 13.2988], label: "Label end" },
    ],
    pinImage: "default",
    options: {
      scale: 0.9,
      pinColor: "FF0000",
      labelColor: "0000FF",
      labelSizeInPixels: 18,
    },
  },
];

const path = createPinsQuery(pins);

const response = await client
  .path("/map/static")
  .get({
    queryParameters: {
      bbox: [13.228, 52.4559, 13.5794, 52.62],
      zoom: 10,
      path,
    },
    skipUrlEncoding: true,
  })
  .asNodeStream();

// Handle the error.
if (!response.body) {
  throw Error("No response body");
}

response.body.pipe(createWriteStream("pin.png"));
default(AzureKeyCredential, ClientOptions)

从订阅密钥创建 MapsRenderClient 的实例。

示例

import { AzureKeyCredential } from "@azure/core-auth";
import MapsRender from "@azure-rest/maps-render";

const credential = new AzureKeyCredential("<subscription-key>");
const client = MapsRender(credential);
default(TokenCredential, string, ClientOptions)

从 Azure 标识 TokenCredential创建 MapsRender 实例。

示例

import { DefaultAzureCredential } from "@azure/identity";
import MapsRender from "@azure-rest/maps-render";

const credential = new DefaultAzureCredential();
const client = MapsRender(credential, "<maps-account-client-id>");
default(AzureSASCredential, ClientOptions)

从 Azure 标识 AzureSASCredential创建 MapsRender 实例。

示例

import { AzureSASCredential } from "@azure/core-auth";
import MapsRender from "@azure-rest/maps-render";

const credential = new AzureSASCredential("<SAS Token>");
const client = MapsRender(credential);
isUnexpected(RenderGetMapTile200Response | RenderGetMapTileDefaultResponse)
isUnexpected(RenderGetMapTileset200Response | RenderGetMapTilesetDefaultResponse)
isUnexpected(RenderGetMapAttribution200Response | RenderGetMapAttributionDefaultResponse)
isUnexpected(RenderGetMapStateTile200Response | RenderGetMapStateTileDefaultResponse)
isUnexpected(RenderGetCopyrightCaption200Response | RenderGetCopyrightCaptionDefaultResponse)
isUnexpected(RenderGetMapStaticImage200Response | RenderGetMapStaticImageDefaultResponse)
isUnexpected(RenderGetCopyrightFromBoundingBox200Response | RenderGetCopyrightFromBoundingBoxDefaultResponse)
isUnexpected(RenderGetCopyrightForTile200Response | RenderGetCopyrightForTileDefaultResponse)
isUnexpected(RenderGetCopyrightForWorld200Response | RenderGetCopyrightForWorldDefaultResponse)
positionToTileXY(LatLon, number, "256" | "512")

计算坐标在特定缩放级别所属于的 XY 磁贴坐标。 参考:https://learn.microsoft.com/en-us/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code

示例

import { DefaultAzureCredential } from "@azure/identity";
import MapsRender, { positionToTileXY } from "@azure-rest/maps-render";
import { createWriteStream } from "node:fs";

const credential = new DefaultAzureCredential();
const client = MapsRender(credential, "<maps-account-client-id>");

const zoom = 6;
// Use the helper function `positionToTileXY` to get the tile index from the coordinate.
const { x, y } = positionToTileXY([47.61559, -122.33817], 6, "256");
const response = await client
  .path("/map/tile")
  .get({
    queryParameters: {
      tilesetId: "microsoft.base.road",
      zoom,
      x,
      y,
    },
  })
  .asNodeStream();

// Handle the error.
if (!response.body) {
  throw Error("No response body");
}

response.body.pipe(createWriteStream("tile.png"));

函数详细信息

createPathQuery((PolygonalPath | CircularPath)[])

获取地图静态图像 请求创建路径查询字符串。

示例

import { DefaultAzureCredential } from "@azure/identity";
import MapsRender, { CircularPath, PolygonalPath, createPathQuery } from "@azure-rest/maps-render";
import { createWriteStream } from "node:fs";

const credential = new DefaultAzureCredential();
const client = MapsRender(credential, "<maps-account-client-id>");

const circularPath: CircularPath = {
  center: [52.4559, 13.228],
  radiusInMeters: 10000,
  options: {
    lineColor: "000000",
    lineOpacity: 0.9,
    lineWidthInPixels: 2,
  },
};

const linearPath: PolygonalPath = {
  coordinates: [
    [52.577, 13.35],
    [52.6, 13.2988],
    [52.32, 13.2988],
  ],
  options: {
    lineColor: "000000",
    lineOpacity: 0.9,
    lineWidthInPixels: 2,
  },
};

const polygonPath: PolygonalPath = {
  coordinates: [
    [52.577, 13.35],
    [52.6, 13.2988],
    [52.32, 13.2988],
    [52.577, 13.35],
  ],
  options: {
    lineColor: "000000",
    lineOpacity: 0.9,
    lineWidthInPixels: 2,
    fillColor: "FFFFFF",
    fillOpacity: 0.8,
  },
};

const path = createPathQuery([circularPath, linearPath, polygonPath]);
// Send the request
const response = await client
  .path("/map/static")
  .get({
    queryParameters: {
      bbox: [13.228, 52.4559, 13.5794, 52.629],
      path,
    },
  })
  .asNodeStream();

// Handle the error.
if (!response.body) {
  throw Error("No response body");
}

response.body.pipe(createWriteStream("path.png"));
function createPathQuery(paths: (PolygonalPath | CircularPath)[]): string

参数

paths

(PolygonalPath | CircularPath)[]

要绘制在图像上的 PolygonalPathCircularPath 的集合。

返回

string

createPinsQuery(PinSet[])

获取地图静态图像创建固定查询字符串

示例

import { DefaultAzureCredential } from "@azure/identity";
import MapsRender, { PinSet, createPinsQuery } from "@azure-rest/maps-render";
import { createWriteStream } from "node:fs";

const credential = new DefaultAzureCredential();
const client = MapsRender(credential, "<maps-account-client-id>");

const pins: PinSet[] = [
  {
    pins: [
      { coordinate: [52.577, 13.35], label: "Label start" },
      { coordinate: [52.6, 13.2988], label: "Label end" },
    ],
    pinImage: "default",
    options: {
      scale: 0.9,
      pinColor: "FF0000",
      labelColor: "0000FF",
      labelSizeInPixels: 18,
    },
  },
];

const path = createPinsQuery(pins);

const response = await client
  .path("/map/static")
  .get({
    queryParameters: {
      bbox: [13.228, 52.4559, 13.5794, 52.62],
      zoom: 10,
      path,
    },
    skipUrlEncoding: true,
  })
  .asNodeStream();

// Handle the error.
if (!response.body) {
  throw Error("No response body");
}

response.body.pipe(createWriteStream("pin.png"));
function createPinsQuery(pinSets: PinSet[]): string

参数

pinSets

PinSet[]

返回

string

  • 组合查询字符串。

default(AzureKeyCredential, ClientOptions)

从订阅密钥创建 MapsRenderClient 的实例。

示例

import { AzureKeyCredential } from "@azure/core-auth";
import MapsRender from "@azure-rest/maps-render";

const credential = new AzureKeyCredential("<subscription-key>");
const client = MapsRender(credential);
function default(credential: AzureKeyCredential, options?: ClientOptions): MapsRenderClient

参数

credential
AzureKeyCredential

用于对服务请求进行身份验证的 AzureKeyCredential 实例

options
ClientOptions

用于配置呈现客户端的选项

返回

default(TokenCredential, string, ClientOptions)

从 Azure 标识 TokenCredential创建 MapsRender 实例。

示例

import { DefaultAzureCredential } from "@azure/identity";
import MapsRender from "@azure-rest/maps-render";

const credential = new DefaultAzureCredential();
const client = MapsRender(credential, "<maps-account-client-id>");
function default(credential: TokenCredential, mapsAccountClientId: string, options?: ClientOptions): MapsRenderClient

参数

credential
TokenCredential

用于对服务的请求进行身份验证的 TokenCredential 实例

mapsAccountClientId

string

特定地图资源的 Azure Maps 客户端 ID

options
ClientOptions

用于配置呈现客户端的选项

返回

default(AzureSASCredential, ClientOptions)

从 Azure 标识 AzureSASCredential创建 MapsRender 实例。

示例

import { AzureSASCredential } from "@azure/core-auth";
import MapsRender from "@azure-rest/maps-render";

const credential = new AzureSASCredential("<SAS Token>");
const client = MapsRender(credential);
function default(credential: AzureSASCredential, options?: ClientOptions): MapsRenderClient

参数

credential
AzureSASCredential

用于对服务的请求进行身份验证的 AzureSASCredential 实例

options
ClientOptions

用于配置呈现客户端的选项

返回

isUnexpected(RenderGetMapTile200Response | RenderGetMapTileDefaultResponse)

function isUnexpected(response: RenderGetMapTile200Response | RenderGetMapTileDefaultResponse): response

参数

返回

response

isUnexpected(RenderGetMapTileset200Response | RenderGetMapTilesetDefaultResponse)

function isUnexpected(response: RenderGetMapTileset200Response | RenderGetMapTilesetDefaultResponse): response

参数

返回

response

isUnexpected(RenderGetMapAttribution200Response | RenderGetMapAttributionDefaultResponse)

function isUnexpected(response: RenderGetMapAttribution200Response | RenderGetMapAttributionDefaultResponse): response

参数

返回

response

isUnexpected(RenderGetMapStateTile200Response | RenderGetMapStateTileDefaultResponse)

function isUnexpected(response: RenderGetMapStateTile200Response | RenderGetMapStateTileDefaultResponse): response

参数

返回

response

isUnexpected(RenderGetCopyrightCaption200Response | RenderGetCopyrightCaptionDefaultResponse)

function isUnexpected(response: RenderGetCopyrightCaption200Response | RenderGetCopyrightCaptionDefaultResponse): response

参数

返回

response

isUnexpected(RenderGetMapStaticImage200Response | RenderGetMapStaticImageDefaultResponse)

function isUnexpected(response: RenderGetMapStaticImage200Response | RenderGetMapStaticImageDefaultResponse): response

参数

返回

response

isUnexpected(RenderGetCopyrightFromBoundingBox200Response | RenderGetCopyrightFromBoundingBoxDefaultResponse)

function isUnexpected(response: RenderGetCopyrightFromBoundingBox200Response | RenderGetCopyrightFromBoundingBoxDefaultResponse): response

参数

返回

response

isUnexpected(RenderGetCopyrightForTile200Response | RenderGetCopyrightForTileDefaultResponse)

function isUnexpected(response: RenderGetCopyrightForTile200Response | RenderGetCopyrightForTileDefaultResponse): response

参数

返回

response

isUnexpected(RenderGetCopyrightForWorld200Response | RenderGetCopyrightForWorldDefaultResponse)

function isUnexpected(response: RenderGetCopyrightForWorld200Response | RenderGetCopyrightForWorldDefaultResponse): response

参数

返回

response

positionToTileXY(LatLon, number, "256" | "512")

计算坐标在特定缩放级别所属于的 XY 磁贴坐标。 参考:https://learn.microsoft.com/en-us/azure/azure-maps/zoom-levels-and-tile-grid?tabs=typescript#tile-math-source-code

示例

import { DefaultAzureCredential } from "@azure/identity";
import MapsRender, { positionToTileXY } from "@azure-rest/maps-render";
import { createWriteStream } from "node:fs";

const credential = new DefaultAzureCredential();
const client = MapsRender(credential, "<maps-account-client-id>");

const zoom = 6;
// Use the helper function `positionToTileXY` to get the tile index from the coordinate.
const { x, y } = positionToTileXY([47.61559, -122.33817], 6, "256");
const response = await client
  .path("/map/tile")
  .get({
    queryParameters: {
      tilesetId: "microsoft.base.road",
      zoom,
      x,
      y,
    },
  })
  .asNodeStream();

// Handle the error.
if (!response.body) {
  throw Error("No response body");
}

response.body.pipe(createWriteStream("tile.png"));
function positionToTileXY(position: LatLon, zoom: number, tileSize: "256" | "512"): { x: number, y: number }

参数

position
LatLon

位置坐标格式为 [纬度, 经度]。

zoom

number

缩放级别。

tileSize

"256" | "512"

图块棱锥图中的磁贴大小。

返回

{ x: number, y: number }

平铺 XY 坐标。