@azure-rest/maps-render 2.0.0-beta.1 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -4
- package/README.md +48 -34
- package/dist/browser/createMultiCollection.d.ts +7 -0
- package/dist/browser/createMultiCollection.d.ts.map +1 -0
- package/dist/browser/createPathQuery.d.ts +117 -0
- package/dist/browser/createPathQuery.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/createPathQuery.js +41 -24
- package/dist/browser/createPathQuery.js.map +1 -0
- package/dist/browser/createPinsQuery.d.ts +102 -0
- package/dist/browser/createPinsQuery.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/createPinsQuery.js +44 -25
- package/dist/browser/createPinsQuery.js.map +1 -0
- package/dist/browser/generated/clientDefinitions.d.ts +131 -0
- package/dist/browser/generated/clientDefinitions.d.ts.map +1 -0
- package/dist/browser/generated/clientDefinitions.js +4 -0
- package/dist/browser/generated/clientDefinitions.js.map +1 -0
- package/dist/browser/generated/index.d.ts +9 -0
- package/dist/browser/generated/index.d.ts.map +1 -0
- package/dist/browser/generated/index.js +11 -0
- package/dist/browser/generated/index.js.map +1 -0
- package/dist/browser/generated/isUnexpected.d.ts +11 -0
- package/dist/browser/generated/isUnexpected.d.ts.map +1 -0
- package/dist/browser/generated/isUnexpected.js +79 -0
- package/dist/browser/generated/isUnexpected.js.map +1 -0
- package/dist/browser/generated/logger.d.ts +2 -0
- package/dist/browser/generated/logger.d.ts.map +1 -0
- package/dist/browser/generated/logger.js +5 -0
- package/dist/browser/generated/logger.js.map +1 -0
- package/dist/browser/generated/mapsRenderClient.d.ts +15 -0
- package/dist/browser/generated/mapsRenderClient.d.ts.map +1 -0
- package/dist/browser/generated/mapsRenderClient.js +42 -0
- package/dist/browser/generated/mapsRenderClient.js.map +1 -0
- package/dist/browser/generated/outputModels.d.ts +93 -0
- package/dist/browser/generated/outputModels.d.ts.map +1 -0
- package/dist/browser/generated/outputModels.js +4 -0
- package/dist/browser/generated/outputModels.js.map +1 -0
- package/dist/browser/generated/parameters.d.ts +384 -0
- package/dist/browser/generated/parameters.d.ts.map +1 -0
- package/dist/browser/generated/parameters.js +4 -0
- package/dist/browser/generated/parameters.js.map +1 -0
- package/dist/browser/generated/responses.d.ts +248 -0
- package/dist/browser/generated/responses.d.ts.map +1 -0
- package/dist/browser/generated/responses.js +4 -0
- package/dist/browser/generated/responses.js.map +1 -0
- package/dist/browser/index.d.ts +7 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +9 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/mapsRender.d.ts +53 -0
- package/dist/browser/mapsRender.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/mapsRender.js +1 -1
- package/dist/browser/mapsRender.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/positionToTileXY.d.ts +47 -0
- package/dist/browser/positionToTileXY.d.ts.map +1 -0
- package/{dist-esm/src → dist/browser}/positionToTileXY.js +23 -2
- package/dist/browser/positionToTileXY.js.map +1 -0
- package/dist/commonjs/createMultiCollection.d.ts +7 -0
- package/dist/commonjs/createMultiCollection.d.ts.map +1 -0
- package/dist/commonjs/createMultiCollection.js +16 -0
- package/dist/commonjs/createMultiCollection.js.map +1 -0
- package/dist/commonjs/createPathQuery.d.ts +117 -0
- package/dist/commonjs/createPathQuery.d.ts.map +1 -0
- package/dist/commonjs/createPathQuery.js +117 -0
- package/dist/commonjs/createPathQuery.js.map +1 -0
- package/dist/commonjs/createPinsQuery.d.ts +102 -0
- package/dist/commonjs/createPinsQuery.d.ts.map +1 -0
- package/dist/commonjs/createPinsQuery.js +96 -0
- package/dist/commonjs/createPinsQuery.js.map +1 -0
- package/dist/commonjs/generated/clientDefinitions.d.ts +131 -0
- package/dist/commonjs/generated/clientDefinitions.d.ts.map +1 -0
- package/dist/commonjs/generated/clientDefinitions.js +5 -0
- package/dist/commonjs/generated/clientDefinitions.js.map +1 -0
- package/dist/commonjs/generated/index.d.ts +9 -0
- package/dist/commonjs/generated/index.d.ts.map +1 -0
- package/dist/commonjs/generated/index.js +14 -0
- package/dist/commonjs/generated/index.js.map +1 -0
- package/dist/commonjs/generated/isUnexpected.d.ts +11 -0
- package/dist/commonjs/generated/isUnexpected.d.ts.map +1 -0
- package/dist/commonjs/generated/isUnexpected.js +82 -0
- package/dist/commonjs/generated/isUnexpected.js.map +1 -0
- package/dist/commonjs/generated/logger.d.ts +2 -0
- package/dist/commonjs/generated/logger.d.ts.map +1 -0
- package/dist/commonjs/generated/logger.js +8 -0
- package/dist/commonjs/generated/logger.js.map +1 -0
- package/dist/commonjs/generated/mapsRenderClient.d.ts +15 -0
- package/dist/commonjs/generated/mapsRenderClient.d.ts.map +1 -0
- package/dist/commonjs/generated/mapsRenderClient.js +45 -0
- package/dist/commonjs/generated/mapsRenderClient.js.map +1 -0
- package/dist/commonjs/generated/outputModels.d.ts +93 -0
- package/dist/commonjs/generated/outputModels.d.ts.map +1 -0
- package/dist/commonjs/generated/outputModels.js +5 -0
- package/dist/commonjs/generated/outputModels.js.map +1 -0
- package/dist/commonjs/generated/parameters.d.ts +384 -0
- package/dist/commonjs/generated/parameters.d.ts.map +1 -0
- package/dist/commonjs/generated/parameters.js +5 -0
- package/dist/commonjs/generated/parameters.js.map +1 -0
- package/dist/commonjs/generated/responses.d.ts +248 -0
- package/dist/commonjs/generated/responses.d.ts.map +1 -0
- package/dist/commonjs/generated/responses.js +5 -0
- package/dist/commonjs/generated/responses.js.map +1 -0
- package/dist/commonjs/index.d.ts +7 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +12 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/mapsRender.d.ts +53 -0
- package/dist/commonjs/mapsRender.d.ts.map +1 -0
- package/dist/commonjs/mapsRender.js +44 -0
- package/dist/commonjs/mapsRender.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/positionToTileXY.d.ts +47 -0
- package/dist/commonjs/positionToTileXY.d.ts.map +1 -0
- package/dist/commonjs/positionToTileXY.js +68 -0
- package/dist/commonjs/positionToTileXY.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/esm/createMultiCollection.d.ts +7 -0
- package/dist/esm/createMultiCollection.d.ts.map +1 -0
- package/dist/esm/createMultiCollection.js +13 -0
- package/dist/esm/createMultiCollection.js.map +1 -0
- package/dist/esm/createPathQuery.d.ts +117 -0
- package/dist/esm/createPathQuery.d.ts.map +1 -0
- package/dist/esm/createPathQuery.js +114 -0
- package/dist/esm/createPathQuery.js.map +1 -0
- package/dist/esm/createPinsQuery.d.ts +102 -0
- package/dist/esm/createPinsQuery.d.ts.map +1 -0
- package/dist/esm/createPinsQuery.js +93 -0
- package/dist/esm/createPinsQuery.js.map +1 -0
- package/dist/esm/generated/clientDefinitions.d.ts +131 -0
- package/dist/esm/generated/clientDefinitions.d.ts.map +1 -0
- package/dist/esm/generated/clientDefinitions.js +4 -0
- package/dist/esm/generated/clientDefinitions.js.map +1 -0
- package/dist/esm/generated/index.d.ts +9 -0
- package/dist/esm/generated/index.d.ts.map +1 -0
- package/dist/esm/generated/index.js +11 -0
- package/dist/esm/generated/index.js.map +1 -0
- package/dist/esm/generated/isUnexpected.d.ts +11 -0
- package/dist/esm/generated/isUnexpected.d.ts.map +1 -0
- package/dist/esm/generated/isUnexpected.js +79 -0
- package/dist/esm/generated/isUnexpected.js.map +1 -0
- package/dist/esm/generated/logger.d.ts +2 -0
- package/dist/esm/generated/logger.d.ts.map +1 -0
- package/dist/esm/generated/logger.js +5 -0
- package/dist/esm/generated/logger.js.map +1 -0
- package/dist/esm/generated/mapsRenderClient.d.ts +15 -0
- package/dist/esm/generated/mapsRenderClient.d.ts.map +1 -0
- package/dist/esm/generated/mapsRenderClient.js +42 -0
- package/dist/esm/generated/mapsRenderClient.js.map +1 -0
- package/dist/esm/generated/outputModels.d.ts +93 -0
- package/dist/esm/generated/outputModels.d.ts.map +1 -0
- package/dist/esm/generated/outputModels.js +4 -0
- package/dist/esm/generated/outputModels.js.map +1 -0
- package/dist/esm/generated/parameters.d.ts +384 -0
- package/dist/esm/generated/parameters.d.ts.map +1 -0
- package/dist/esm/generated/parameters.js +4 -0
- package/dist/esm/generated/parameters.js.map +1 -0
- package/dist/esm/generated/responses.d.ts +248 -0
- package/dist/esm/generated/responses.d.ts.map +1 -0
- package/dist/esm/generated/responses.js +4 -0
- package/dist/esm/generated/responses.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mapsRender.d.ts +53 -0
- package/dist/esm/mapsRender.d.ts.map +1 -0
- package/dist/esm/mapsRender.js +40 -0
- package/dist/esm/mapsRender.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/positionToTileXY.d.ts +47 -0
- package/dist/esm/positionToTileXY.d.ts.map +1 -0
- package/dist/esm/positionToTileXY.js +65 -0
- package/dist/esm/positionToTileXY.js.map +1 -0
- package/dist/react-native/createMultiCollection.d.ts +7 -0
- package/dist/react-native/createMultiCollection.d.ts.map +1 -0
- package/dist/react-native/createMultiCollection.js +13 -0
- package/dist/react-native/createMultiCollection.js.map +1 -0
- package/dist/react-native/createPathQuery.d.ts +117 -0
- package/dist/react-native/createPathQuery.d.ts.map +1 -0
- package/dist/react-native/createPathQuery.js +114 -0
- package/dist/react-native/createPathQuery.js.map +1 -0
- package/dist/react-native/createPinsQuery.d.ts +102 -0
- package/dist/react-native/createPinsQuery.d.ts.map +1 -0
- package/dist/react-native/createPinsQuery.js +93 -0
- package/dist/react-native/createPinsQuery.js.map +1 -0
- package/dist/react-native/generated/clientDefinitions.d.ts +131 -0
- package/dist/react-native/generated/clientDefinitions.d.ts.map +1 -0
- package/dist/react-native/generated/clientDefinitions.js +4 -0
- package/dist/react-native/generated/clientDefinitions.js.map +1 -0
- package/dist/react-native/generated/index.d.ts +9 -0
- package/dist/react-native/generated/index.d.ts.map +1 -0
- package/dist/react-native/generated/index.js +11 -0
- package/dist/react-native/generated/index.js.map +1 -0
- package/dist/react-native/generated/isUnexpected.d.ts +11 -0
- package/dist/react-native/generated/isUnexpected.d.ts.map +1 -0
- package/dist/react-native/generated/isUnexpected.js +79 -0
- package/dist/react-native/generated/isUnexpected.js.map +1 -0
- package/dist/react-native/generated/logger.d.ts +2 -0
- package/dist/react-native/generated/logger.d.ts.map +1 -0
- package/dist/react-native/generated/logger.js +5 -0
- package/dist/react-native/generated/logger.js.map +1 -0
- package/dist/react-native/generated/mapsRenderClient.d.ts +15 -0
- package/dist/react-native/generated/mapsRenderClient.d.ts.map +1 -0
- package/dist/react-native/generated/mapsRenderClient.js +42 -0
- package/dist/react-native/generated/mapsRenderClient.js.map +1 -0
- package/dist/react-native/generated/outputModels.d.ts +93 -0
- package/dist/react-native/generated/outputModels.d.ts.map +1 -0
- package/dist/react-native/generated/outputModels.js +4 -0
- package/dist/react-native/generated/outputModels.js.map +1 -0
- package/dist/react-native/generated/parameters.d.ts +384 -0
- package/dist/react-native/generated/parameters.d.ts.map +1 -0
- package/dist/react-native/generated/parameters.js +4 -0
- package/dist/react-native/generated/parameters.js.map +1 -0
- package/dist/react-native/generated/responses.d.ts +248 -0
- package/dist/react-native/generated/responses.d.ts.map +1 -0
- package/dist/react-native/generated/responses.js +4 -0
- package/dist/react-native/generated/responses.js.map +1 -0
- package/dist/react-native/index.d.ts +7 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +9 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/react-native/mapsRender.d.ts +53 -0
- package/dist/react-native/mapsRender.d.ts.map +1 -0
- package/dist/react-native/mapsRender.js +40 -0
- package/dist/react-native/mapsRender.js.map +1 -0
- package/dist/react-native/package.json +3 -0
- package/dist/react-native/positionToTileXY.d.ts +47 -0
- package/dist/react-native/positionToTileXY.d.ts.map +1 -0
- package/dist/react-native/positionToTileXY.js +65 -0
- package/dist/react-native/positionToTileXY.js.map +1 -0
- package/package.json +73 -52
- package/dist/index.js +0 -404
- package/dist/index.js.map +0 -1
- package/dist-esm/src/createPathQuery.js.map +0 -1
- package/dist-esm/src/createPinsQuery.js.map +0 -1
- package/dist-esm/src/index.js +0 -9
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/src/mapsRender.js.map +0 -1
- package/dist-esm/src/positionToTileXY.js.map +0 -1
- package/review/maps-render.api.md +0 -564
- package/types/maps-render-rest.d.ts +0 -1212
- /package/{dist-esm/src → dist/browser}/createMultiCollection.js +0 -0
- /package/{dist-esm/src → dist/browser}/createMultiCollection.js.map +0 -0
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
Copyright (c) Microsoft Corporation.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
MIT License
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -12,10 +12,10 @@ furnished to do so, subject to the following conditions:
|
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
|
13
13
|
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
|
-
THE SOFTWARE IS PROVIDED
|
|
15
|
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Key links:
|
|
|
12
12
|
- [Product Information][product_info]
|
|
13
13
|
|
|
14
14
|
| Package Version | Service Version |
|
|
15
|
-
|
|
15
|
+
| --------------- | --------------- |
|
|
16
16
|
| ^1.0.0-beta.4 | V1 |
|
|
17
17
|
| ^2.0.0-beta.1 | 2024-04-01 |
|
|
18
18
|
|
|
@@ -62,11 +62,11 @@ You'll need to register the new Microsoft Entra ID application and grant access
|
|
|
62
62
|
`AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
|
|
63
63
|
|
|
64
64
|
You will also need to specify the Azure Maps resource you intend to use by specifying the `clientId` in the client options.
|
|
65
|
-
The Azure Maps resource client id can be found in the Authentication sections in the Azure Maps resource. Please refer to the [documentation](https://
|
|
65
|
+
The Azure Maps resource client id can be found in the Authentication sections in the Azure Maps resource. Please refer to the [documentation](https://learn.microsoft.com/azure/azure-maps/how-to-manage-authentication#view-authentication-details) on how to find it.
|
|
66
66
|
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
68
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
69
|
+
import MapsRender from "@azure-rest/maps-render";
|
|
70
70
|
|
|
71
71
|
const credential = new DefaultAzureCredential();
|
|
72
72
|
const client = MapsRender(credential, "<maps-account-client-id>");
|
|
@@ -80,9 +80,9 @@ You can authenticate with your Azure Maps Subscription Key. Please install the["
|
|
|
80
80
|
npm install @azure/core-auth
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
84
|
+
import { AzureKeyCredential } from "@azure/core-auth";
|
|
85
|
+
import MapsRender from "@azure-rest/maps-render";
|
|
86
86
|
|
|
87
87
|
const credential = new AzureKeyCredential("<subscription-key>");
|
|
88
88
|
const client = MapsRender(credential);
|
|
@@ -104,11 +104,11 @@ npm install @azure/core-auth
|
|
|
104
104
|
|
|
105
105
|
Finally, you can use the SAS token to authenticate the client:
|
|
106
106
|
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
```ts snippet:ReadmeSampleCreateClient_SAS
|
|
108
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
109
|
+
import { AzureMapsManagementClient } from "@azure/arm-maps";
|
|
110
|
+
import { AzureSASCredential } from "@azure/core-auth";
|
|
111
|
+
import MapsRender from "@azure-rest/maps-render";
|
|
112
112
|
|
|
113
113
|
const subscriptionId = "<subscription ID of the map account>";
|
|
114
114
|
const resourceGroupName = "<resource group name of the map account>";
|
|
@@ -120,6 +120,7 @@ const mapsAccountSasParameters = {
|
|
|
120
120
|
principalId: "<principle ID (object ID) of the managed identity>",
|
|
121
121
|
signingKey: "primaryKey",
|
|
122
122
|
};
|
|
123
|
+
|
|
123
124
|
const credential = new DefaultAzureCredential();
|
|
124
125
|
const managementClient = new AzureMapsManagementClient(credential, subscriptionId);
|
|
125
126
|
const { accountSasToken } = await managementClient.accounts.listSas(
|
|
@@ -127,9 +128,11 @@ const { accountSasToken } = await managementClient.accounts.listSas(
|
|
|
127
128
|
accountName,
|
|
128
129
|
mapsAccountSasParameters,
|
|
129
130
|
);
|
|
131
|
+
|
|
130
132
|
if (accountSasToken === undefined) {
|
|
131
133
|
throw new Error("No accountSasToken was found for the Maps Account.");
|
|
132
134
|
}
|
|
135
|
+
|
|
133
136
|
const sasCredential = new AzureSASCredential(accountSasToken);
|
|
134
137
|
const client = MapsRender(sasCredential);
|
|
135
138
|
```
|
|
@@ -151,11 +154,15 @@ The following sections provide several code snippets covering some of the most c
|
|
|
151
154
|
### Request map tiles in vector or raster formats
|
|
152
155
|
|
|
153
156
|
You can request map tiles in vector or raster formats. These tiles are typically to be integrated into a map control or SDK.
|
|
154
|
-
Some example tiles that can be requested are Azure Maps road tiles, real-time Weather Radar tiles or the map tiles created using [Azure Maps Creator](https://
|
|
157
|
+
Some example tiles that can be requested are Azure Maps road tiles, real-time Weather Radar tiles or the map tiles created using [Azure Maps Creator](https://learn.microsoft.com/shows/internet-of-things-show/introducing-azure-maps-creator).
|
|
155
158
|
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
```ts snippet:ReadmeSampleRequestMapTiles
|
|
160
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
161
|
+
import MapsRender, { positionToTileXY } from "@azure-rest/maps-render";
|
|
162
|
+
import { createWriteStream } from "node:fs";
|
|
163
|
+
|
|
164
|
+
const credential = new DefaultAzureCredential();
|
|
165
|
+
const client = MapsRender(credential, "<maps-account-client-id>");
|
|
159
166
|
|
|
160
167
|
const zoom = 6;
|
|
161
168
|
// Use the helper function `positionToTileXY` to get the tile index from the coordinate.
|
|
@@ -176,22 +183,27 @@ const response = await client
|
|
|
176
183
|
if (!response.body) {
|
|
177
184
|
throw Error("No response body");
|
|
178
185
|
}
|
|
186
|
+
|
|
179
187
|
response.body.pipe(createWriteStream("tile.png"));
|
|
180
188
|
```
|
|
181
189
|
|
|
182
190
|
### Request map copyright attribution information
|
|
183
191
|
|
|
184
192
|
You can request map copyright attribution information for a section of a tileset.
|
|
185
|
-
A tileset is a collection of raster or vector data broken up into a uniform grid of square tiles at preset zoom levels. Every tileset has a tilesetId to use when making requests. The supported tilesetIds are listed [here](https://
|
|
193
|
+
A tileset is a collection of raster or vector data broken up into a uniform grid of square tiles at preset zoom levels. Every tileset has a tilesetId to use when making requests. The supported tilesetIds are listed [here](https://learn.microsoft.com/rest/api/maps/render/get-map-attribution?tabs=HTTP#tilesetid).
|
|
186
194
|
|
|
187
|
-
```
|
|
188
|
-
|
|
195
|
+
```ts snippet:ReadmeSampleRequestMapAttribution
|
|
196
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
197
|
+
import MapsRender, { isUnexpected } from "@azure-rest/maps-render";
|
|
198
|
+
|
|
199
|
+
const credential = new DefaultAzureCredential();
|
|
200
|
+
const client = MapsRender(credential, "<maps-account-client-id>");
|
|
189
201
|
|
|
190
202
|
const response = await client.path("/map/attribution").get({
|
|
191
203
|
queryParameters: {
|
|
192
204
|
tilesetId: "microsoft.base",
|
|
193
205
|
zoom: 6,
|
|
194
|
-
|
|
206
|
+
// The order is [SouthwestCorner_Longitude, SouthwestCorner_Latitude, NortheastCorner_Longitude, NortheastCorner_Latitude]
|
|
195
207
|
bounds: [-122.414162, 47.57949, -122.247157, 47.668372],
|
|
196
208
|
},
|
|
197
209
|
});
|
|
@@ -209,8 +221,12 @@ response.body.copyrights.forEach((copyright) => console.log(copyright));
|
|
|
209
221
|
|
|
210
222
|
You can request metadata for a tileset in TileJSON format using the following code snippet.
|
|
211
223
|
|
|
212
|
-
```
|
|
213
|
-
|
|
224
|
+
```ts snippet:ReadmeSampleRequestTilesetMetadata
|
|
225
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
226
|
+
import MapsRender, { isUnexpected } from "@azure-rest/maps-render";
|
|
227
|
+
|
|
228
|
+
const credential = new DefaultAzureCredential();
|
|
229
|
+
const client = MapsRender(credential, "<maps-account-client-id>");
|
|
214
230
|
|
|
215
231
|
const response = await client.path("/map/tileset").get({
|
|
216
232
|
queryParameters: {
|
|
@@ -236,8 +252,8 @@ console.log(
|
|
|
236
252
|
|
|
237
253
|
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
238
254
|
|
|
239
|
-
```
|
|
240
|
-
|
|
255
|
+
```ts snippet:SetLogLevel
|
|
256
|
+
import { setLogLevel } from "@azure/logger";
|
|
241
257
|
|
|
242
258
|
setLogLevel("info");
|
|
243
259
|
```
|
|
@@ -256,19 +272,17 @@ If you'd like to contribute to this library, please read the [contributing guide
|
|
|
256
272
|
|
|
257
273
|
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
|
|
258
274
|
|
|
259
|
-

|
|
260
|
-
|
|
261
275
|
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-render-rest
|
|
262
276
|
[npm_package]: https://www.npmjs.com/package/@azure-rest/maps-render
|
|
263
|
-
[api_ref]: https://
|
|
277
|
+
[api_ref]: https://learn.microsoft.com/javascript/api/@azure-rest/maps-render?view=azure-node-preview
|
|
264
278
|
[samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-render-rest/samples
|
|
265
|
-
[product_info]: https://
|
|
279
|
+
[product_info]: https://learn.microsoft.com/rest/api/maps/render
|
|
266
280
|
[nodejs_release]: https://github.com/nodejs/release#release-schedule
|
|
267
281
|
[az_subscription]: https://azure.microsoft.com/free/
|
|
268
|
-
[az_maps_account_management]: https://
|
|
282
|
+
[az_maps_account_management]: https://learn.microsoft.com/azure/azure-maps/how-to-manage-account-keys
|
|
269
283
|
[azure_portal]: https://portal.azure.com
|
|
270
|
-
[azure_powershell]: https://
|
|
271
|
-
[azure_cli]: https://
|
|
272
|
-
[az_map_pricing]: https://
|
|
273
|
-
[az_map_az_cli]: https://
|
|
284
|
+
[azure_powershell]: https://learn.microsoft.com/powershell/module/az.maps/new-azmapsaccount
|
|
285
|
+
[azure_cli]: https://learn.microsoft.com/cli/azure
|
|
286
|
+
[az_map_pricing]: https://learn.microsoft.com/azure/azure-maps/choose-pricing-tier
|
|
287
|
+
[az_map_az_cli]: https://learn.microsoft.com/cli/azure/maps/account?view=azure-cli-latest#az_maps_account_create
|
|
274
288
|
[az_map_auth]: https://learn.microsoft.com/azure/azure-maps/azure-maps-authentication
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* Workaround to create a path query string for [ collectionFormat: multi ](https://swagger.io/docs/specification/2-0/describing-parameters/#:~:text=csv%20(-,default,-)).
|
|
4
|
+
* This should be removed once the core-client support collectionFormat: multi.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createMultiCollection(key: string, values: string[]): string;
|
|
7
|
+
//# sourceMappingURL=createMultiCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createMultiCollection.d.ts","sourceRoot":"","sources":["../../src/createMultiCollection.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAI3E"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { LatLon } from "@azure/maps-common";
|
|
2
|
+
/**
|
|
3
|
+
* The options that modify the style of a circular path.
|
|
4
|
+
*/
|
|
5
|
+
export interface CircularPathOptions {
|
|
6
|
+
/** The line color of the path. Range from 000000 to FFFFFF. */
|
|
7
|
+
lineColor?: string;
|
|
8
|
+
/** The line opacity of the path. Range from 0 to 1. */
|
|
9
|
+
lineOpacity?: number;
|
|
10
|
+
/** The line width of the line. Should be greater than 0. */
|
|
11
|
+
lineWidthInPixels?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The options that modify the style of a polygonal path.
|
|
15
|
+
*/
|
|
16
|
+
export interface PolygonalPathOptions extends CircularPathOptions {
|
|
17
|
+
/** The fill color of the path. This only works if the path is a closed shape like polygon or circle. Range from 000000 to FFFFFF.*/
|
|
18
|
+
fillColor?: string;
|
|
19
|
+
/** The fill color of the path. This only works if the path is a closed shape like polygon or circle. Range from 0 to 1.*/
|
|
20
|
+
fillOpacity?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Specify a circular path.
|
|
24
|
+
*/
|
|
25
|
+
export interface CircularPath {
|
|
26
|
+
/** The center of the circular path. */
|
|
27
|
+
center: LatLon;
|
|
28
|
+
/** The radius of the circular path. */
|
|
29
|
+
radiusInMeters: number;
|
|
30
|
+
/** The options that modify the style of the circular path. */
|
|
31
|
+
options?: CircularPathOptions;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Specify a polygonal path.
|
|
35
|
+
*/
|
|
36
|
+
export interface PolygonalPath {
|
|
37
|
+
/** The coordinates of the polygonal path. The identical coordinate in the first & last position construct a closed polygon.*/
|
|
38
|
+
coordinates: LatLon[];
|
|
39
|
+
/** The options that modify the style of the polygonal path. */
|
|
40
|
+
options?: PolygonalPathOptions;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create a path query string for _get map static image_ request.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts snippet:ReadmeSampleCreatePathQuery
|
|
47
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
48
|
+
* import MapsRender, { CircularPath, PolygonalPath, createPathQuery } from "@azure-rest/maps-render";
|
|
49
|
+
* import { createWriteStream } from "node:fs";
|
|
50
|
+
*
|
|
51
|
+
* const credential = new DefaultAzureCredential();
|
|
52
|
+
* const client = MapsRender(credential, "<maps-account-client-id>");
|
|
53
|
+
*
|
|
54
|
+
* const circularPath: CircularPath = {
|
|
55
|
+
* center: [52.4559, 13.228],
|
|
56
|
+
* radiusInMeters: 10000,
|
|
57
|
+
* options: {
|
|
58
|
+
* lineColor: "000000",
|
|
59
|
+
* lineOpacity: 0.9,
|
|
60
|
+
* lineWidthInPixels: 2,
|
|
61
|
+
* },
|
|
62
|
+
* };
|
|
63
|
+
*
|
|
64
|
+
* const linearPath: PolygonalPath = {
|
|
65
|
+
* coordinates: [
|
|
66
|
+
* [52.577, 13.35],
|
|
67
|
+
* [52.6, 13.2988],
|
|
68
|
+
* [52.32, 13.2988],
|
|
69
|
+
* ],
|
|
70
|
+
* options: {
|
|
71
|
+
* lineColor: "000000",
|
|
72
|
+
* lineOpacity: 0.9,
|
|
73
|
+
* lineWidthInPixels: 2,
|
|
74
|
+
* },
|
|
75
|
+
* };
|
|
76
|
+
*
|
|
77
|
+
* const polygonPath: PolygonalPath = {
|
|
78
|
+
* coordinates: [
|
|
79
|
+
* [52.577, 13.35],
|
|
80
|
+
* [52.6, 13.2988],
|
|
81
|
+
* [52.32, 13.2988],
|
|
82
|
+
* [52.577, 13.35],
|
|
83
|
+
* ],
|
|
84
|
+
* options: {
|
|
85
|
+
* lineColor: "000000",
|
|
86
|
+
* lineOpacity: 0.9,
|
|
87
|
+
* lineWidthInPixels: 2,
|
|
88
|
+
* fillColor: "FFFFFF",
|
|
89
|
+
* fillOpacity: 0.8,
|
|
90
|
+
* },
|
|
91
|
+
* };
|
|
92
|
+
*
|
|
93
|
+
* const path = createPathQuery([circularPath, linearPath, polygonPath]);
|
|
94
|
+
* // Send the request
|
|
95
|
+
* const response = await client
|
|
96
|
+
* .path("/map/static")
|
|
97
|
+
* .get({
|
|
98
|
+
* queryParameters: {
|
|
99
|
+
* bbox: [13.228, 52.4559, 13.5794, 52.629],
|
|
100
|
+
* path,
|
|
101
|
+
* },
|
|
102
|
+
* })
|
|
103
|
+
* .asNodeStream();
|
|
104
|
+
*
|
|
105
|
+
* // Handle the error.
|
|
106
|
+
* if (!response.body) {
|
|
107
|
+
* throw Error("No response body");
|
|
108
|
+
* }
|
|
109
|
+
*
|
|
110
|
+
* response.body.pipe(createWriteStream("path.png"));
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @param paths - A collection of {@link PolygonalPath} and {@link CircularPath} that you want to draw on the image.
|
|
114
|
+
* @param options - The options for the style of the path. See the possible options in {@link PolygonalPathOptions} and {@link CircularPathOptions}.
|
|
115
|
+
*/
|
|
116
|
+
export declare function createPathQuery(paths: Array<PolygonalPath | CircularPath>): string;
|
|
117
|
+
//# sourceMappingURL=createPathQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPathQuery.d.ts","sourceRoot":"","sources":["../../src/createPathQuery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,oIAAoI;IACpI,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0HAA0H;IAC1H,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,mBAAmB,CAAC;CAC/B;AAKD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8HAA8H;IAC9H,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AA2BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,aAAa,GAAG,YAAY,CAAC,GAAG,MAAM,CASlF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { createMultiCollection } from "./createMultiCollection";
|
|
3
|
+
import { createMultiCollection } from "./createMultiCollection.js";
|
|
4
4
|
function isCircularPath(path) {
|
|
5
5
|
return "center" in path;
|
|
6
6
|
}
|
|
@@ -31,8 +31,15 @@ function comosePathVal(coordinates, options) {
|
|
|
31
31
|
* Create a path query string for _get map static image_ request.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
*
|
|
34
|
+
* ```ts snippet:ReadmeSampleCreatePathQuery
|
|
35
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
36
|
+
* import MapsRender, { CircularPath, PolygonalPath, createPathQuery } from "@azure-rest/maps-render";
|
|
37
|
+
* import { createWriteStream } from "node:fs";
|
|
38
|
+
*
|
|
39
|
+
* const credential = new DefaultAzureCredential();
|
|
40
|
+
* const client = MapsRender(credential, "<maps-account-client-id>");
|
|
41
|
+
*
|
|
42
|
+
* const circularPath: CircularPath = {
|
|
36
43
|
* center: [52.4559, 13.228],
|
|
37
44
|
* radiusInMeters: 10000,
|
|
38
45
|
* options: {
|
|
@@ -42,7 +49,7 @@ function comosePathVal(coordinates, options) {
|
|
|
42
49
|
* },
|
|
43
50
|
* };
|
|
44
51
|
*
|
|
45
|
-
* const linearPath = {
|
|
52
|
+
* const linearPath: PolygonalPath = {
|
|
46
53
|
* coordinates: [
|
|
47
54
|
* [52.577, 13.35],
|
|
48
55
|
* [52.6, 13.2988],
|
|
@@ -55,30 +62,40 @@ function comosePathVal(coordinates, options) {
|
|
|
55
62
|
* },
|
|
56
63
|
* };
|
|
57
64
|
*
|
|
58
|
-
* const polygonPath = {
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
65
|
+
* const polygonPath: PolygonalPath = {
|
|
66
|
+
* coordinates: [
|
|
67
|
+
* [52.577, 13.35],
|
|
68
|
+
* [52.6, 13.2988],
|
|
69
|
+
* [52.32, 13.2988],
|
|
70
|
+
* [52.577, 13.35],
|
|
71
|
+
* ],
|
|
72
|
+
* options: {
|
|
73
|
+
* lineColor: "000000",
|
|
74
|
+
* lineOpacity: 0.9,
|
|
75
|
+
* lineWidthInPixels: 2,
|
|
76
|
+
* fillColor: "FFFFFF",
|
|
77
|
+
* fillOpacity: 0.8,
|
|
78
|
+
* },
|
|
72
79
|
* };
|
|
73
80
|
*
|
|
74
81
|
* const path = createPathQuery([circularPath, linearPath, polygonPath]);
|
|
75
82
|
* // Send the request
|
|
76
|
-
* const response = await client
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
83
|
+
* const response = await client
|
|
84
|
+
* .path("/map/static")
|
|
85
|
+
* .get({
|
|
86
|
+
* queryParameters: {
|
|
87
|
+
* bbox: [13.228, 52.4559, 13.5794, 52.629],
|
|
88
|
+
* path,
|
|
89
|
+
* },
|
|
90
|
+
* })
|
|
91
|
+
* .asNodeStream();
|
|
92
|
+
*
|
|
93
|
+
* // Handle the error.
|
|
94
|
+
* if (!response.body) {
|
|
95
|
+
* throw Error("No response body");
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* response.body.pipe(createWriteStream("path.png"));
|
|
82
99
|
* ```
|
|
83
100
|
*
|
|
84
101
|
* @param paths - A collection of {@link PolygonalPath} and {@link CircularPath} that you want to draw on the image.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPathQuery.js","sourceRoot":"","sources":["../../src/createPathQuery.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAwCnE,SAAS,cAAc,CAAC,IAAkC;IACxD,OAAO,QAAQ,IAAI,IAAI,CAAC;AAC1B,CAAC;AAWD,MAAM,YAAY,GAAgD;IAChE,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,iBAAiB,EAAE,IAAI;IACvB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,GAAG,IAAI,YAAY,CAAC;AAC7B,CAAC;AAED,SAAS,aAAa,CAAC,WAAqB,EAAE,OAA8B;IAC1E,uCAAuC;IACvC,MAAM,mBAAmB,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvF,mCAAmC;IACnC,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;QACtF,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;YAAE,MAAM,KAAK,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC;QACzD,QAAQ,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC;QAC/D,OAAO,QAAQ,CAAC;IAClB,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,eAAe,GAAG,IAAI,GAAG,mBAAmB,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,MAAM,UAAU,eAAe,CAAC,KAA0C;IACxE,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACrC,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YACjD,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,kCAAO,OAAO,KAAE,MAAM,EAAE,cAAc,IAAG,CAAC;QACzE,CAAC;QACD,OAAO,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IACH,OAAO,qBAAqB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACpD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { LatLon } from \"@azure/maps-common\";\nimport { createMultiCollection } from \"./createMultiCollection.js\";\n\n/**\n * The options that modify the style of a circular path.\n */\nexport interface CircularPathOptions {\n /** The line color of the path. Range from 000000 to FFFFFF. */\n lineColor?: string;\n /** The line opacity of the path. Range from 0 to 1. */\n lineOpacity?: number;\n /** The line width of the line. Should be greater than 0. */\n lineWidthInPixels?: number;\n}\n\n/**\n * The options that modify the style of a polygonal path.\n */\nexport interface PolygonalPathOptions extends CircularPathOptions {\n /** The fill color of the path. This only works if the path is a closed shape like polygon or circle. Range from 000000 to FFFFFF.*/\n fillColor?: string;\n /** The fill color of the path. This only works if the path is a closed shape like polygon or circle. Range from 0 to 1.*/\n fillOpacity?: number;\n}\n\ninterface PathOptionsForRequest extends PolygonalPathOptions {\n radius?: number;\n}\n\n/**\n * Specify a circular path.\n */\nexport interface CircularPath {\n /** The center of the circular path. */\n center: LatLon;\n /** The radius of the circular path. */\n radiusInMeters: number;\n /** The options that modify the style of the circular path. */\n options?: CircularPathOptions;\n}\n\nfunction isCircularPath(path: PolygonalPath | CircularPath): path is CircularPath {\n return \"center\" in path;\n}\n/**\n * Specify a polygonal path.\n */\nexport interface PolygonalPath {\n /** The coordinates of the polygonal path. The identical coordinate in the first & last position construct a closed polygon.*/\n coordinates: LatLon[];\n /** The options that modify the style of the polygonal path. */\n options?: PolygonalPathOptions;\n}\n\nconst optionKeyMap: Record<keyof PathOptionsForRequest, string> = {\n lineColor: \"lc\",\n lineOpacity: \"la\",\n fillColor: \"fc\",\n fillOpacity: \"fa\",\n lineWidthInPixels: \"lw\",\n radius: \"ra\",\n};\n\nfunction isOptionKey(key: any): key is keyof PathOptionsForRequest {\n return key in optionKeyMap;\n}\n\nfunction comosePathVal(coordinates: LatLon[], options: PathOptionsForRequest): string {\n // compose the coordinates query string\n const coordinatesQueryStr = coordinates.map(([lat, lon]) => `${lon} ${lat}`).join(\"|\");\n // compose the options query string\n const optionsQueryStr = Object.entries(options).reduce<string>((queryStr, [key, val]) => {\n if (!isOptionKey(key)) throw Error(`Unknown key ${key}`);\n queryStr += `${queryStr ? \"|\" : \"\"}${optionKeyMap[key]}${val}`;\n return queryStr;\n }, \"\");\n return optionsQueryStr + \"||\" + coordinatesQueryStr;\n}\n\n/**\n * Create a path query string for _get map static image_ request.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreatePathQuery\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsRender, { CircularPath, PolygonalPath, createPathQuery } from \"@azure-rest/maps-render\";\n * import { createWriteStream } from \"node:fs\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsRender(credential, \"<maps-account-client-id>\");\n *\n * const circularPath: CircularPath = {\n * center: [52.4559, 13.228],\n * radiusInMeters: 10000,\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * },\n * };\n *\n * const linearPath: PolygonalPath = {\n * coordinates: [\n * [52.577, 13.35],\n * [52.6, 13.2988],\n * [52.32, 13.2988],\n * ],\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * },\n * };\n *\n * const polygonPath: PolygonalPath = {\n * coordinates: [\n * [52.577, 13.35],\n * [52.6, 13.2988],\n * [52.32, 13.2988],\n * [52.577, 13.35],\n * ],\n * options: {\n * lineColor: \"000000\",\n * lineOpacity: 0.9,\n * lineWidthInPixels: 2,\n * fillColor: \"FFFFFF\",\n * fillOpacity: 0.8,\n * },\n * };\n *\n * const path = createPathQuery([circularPath, linearPath, polygonPath]);\n * // Send the request\n * const response = await client\n * .path(\"/map/static\")\n * .get({\n * queryParameters: {\n * bbox: [13.228, 52.4559, 13.5794, 52.629],\n * path,\n * },\n * })\n * .asNodeStream();\n *\n * // Handle the error.\n * if (!response.body) {\n * throw Error(\"No response body\");\n * }\n *\n * response.body.pipe(createWriteStream(\"path.png\"));\n * ```\n *\n * @param paths - A collection of {@link PolygonalPath} and {@link CircularPath} that you want to draw on the image.\n * @param options - The options for the style of the path. See the possible options in {@link PolygonalPathOptions} and {@link CircularPathOptions}.\n */\nexport function createPathQuery(paths: Array<PolygonalPath | CircularPath>): string {\n const pathQueries = paths.map((path) => {\n if (isCircularPath(path)) {\n const { center, radiusInMeters, options } = path;\n return comosePathVal([center], { ...options, radius: radiusInMeters });\n }\n return comosePathVal(path.coordinates, path.options || {});\n });\n return createMultiCollection(\"path\", pathQueries);\n}\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { LatLon } from "@azure/maps-common";
|
|
2
|
+
/**
|
|
3
|
+
* Specify how the pin's position and label text.
|
|
4
|
+
*/
|
|
5
|
+
export interface Pin {
|
|
6
|
+
/** The coordinate of the pin. */
|
|
7
|
+
coordinate: LatLon;
|
|
8
|
+
/** The label text for the pin. */
|
|
9
|
+
label?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The pin options for default/none image style..
|
|
13
|
+
*/
|
|
14
|
+
export interface PinOptions {
|
|
15
|
+
/** The opacity of the pin. Range from 0 to 1 */
|
|
16
|
+
opacity?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The labels are centered at the pushpin 'label anchor.' The anchor location is predefined for built-in pushpins and is at the top center of custom pushpins (see below).
|
|
19
|
+
* To override the label anchor, using the _labelAnchor_ option and provide X and Y pixel coordinates for the anchor.
|
|
20
|
+
* These coordinates are relative to the top left corner of the pushpin image. Positive X values move the anchor to the right, and positive Y values move the anchor down.
|
|
21
|
+
* For example, to position the label anchor 10 pixels right and 4 pixels above the top left corner of the pushpin image, use \{labelAnchor: [10, -4]\}
|
|
22
|
+
* */
|
|
23
|
+
labelAnchor?: [number, number];
|
|
24
|
+
/** Color of the label. Range from 000000 to FFFFFF */
|
|
25
|
+
labelColor?: string;
|
|
26
|
+
/** Size of the label in pixels. */
|
|
27
|
+
labelSizeInPixels?: number;
|
|
28
|
+
/**
|
|
29
|
+
* By default, custom pushpin images are drawn centered at the pin coordinates. This usually isn't ideal as it obscures the location that you're trying to highlight.
|
|
30
|
+
* To override the anchor location of the pin image, use the _pinAnchor_ option. This uses the same format as the _labelAnchor_ options.
|
|
31
|
+
* For example, if your custom pin image has the tip of the pin at the top left corner of the image, you can set the anchor to that spot by using \{pinAnchor: [0, 0]\}
|
|
32
|
+
*/
|
|
33
|
+
pinAnchor?: [number, number];
|
|
34
|
+
/** The ration of the pin. Range from -360 to 360*/
|
|
35
|
+
rotationInDegree?: number;
|
|
36
|
+
/** The scale of the pin. Should be greater than 0. */
|
|
37
|
+
scale?: number;
|
|
38
|
+
/** Color of the pin. Range from 000000 to FFFFFF */
|
|
39
|
+
pinColor?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface PinSet {
|
|
42
|
+
pins: Pin[];
|
|
43
|
+
pinImage?: "default" | "none" | string;
|
|
44
|
+
options?: PinOptions;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a pin query string for _get map static image_
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts snippet:ReadmeSampleCreatePinsQuery
|
|
51
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
52
|
+
* import MapsRender, { PinSet, createPinsQuery } from "@azure-rest/maps-render";
|
|
53
|
+
* import { createWriteStream } from "node:fs";
|
|
54
|
+
*
|
|
55
|
+
* const credential = new DefaultAzureCredential();
|
|
56
|
+
* const client = MapsRender(credential, "<maps-account-client-id>");
|
|
57
|
+
*
|
|
58
|
+
* const pins: PinSet[] = [
|
|
59
|
+
* {
|
|
60
|
+
* pins: [
|
|
61
|
+
* { coordinate: [52.577, 13.35], label: "Label start" },
|
|
62
|
+
* { coordinate: [52.6, 13.2988], label: "Label end" },
|
|
63
|
+
* ],
|
|
64
|
+
* pinImage: "default",
|
|
65
|
+
* options: {
|
|
66
|
+
* scale: 0.9,
|
|
67
|
+
* pinColor: "FF0000",
|
|
68
|
+
* labelColor: "0000FF",
|
|
69
|
+
* labelSizeInPixels: 18,
|
|
70
|
+
* },
|
|
71
|
+
* },
|
|
72
|
+
* ];
|
|
73
|
+
*
|
|
74
|
+
* const path = createPinsQuery(pins);
|
|
75
|
+
*
|
|
76
|
+
* const response = await client
|
|
77
|
+
* .path("/map/static")
|
|
78
|
+
* .get({
|
|
79
|
+
* queryParameters: {
|
|
80
|
+
* bbox: [13.228, 52.4559, 13.5794, 52.62],
|
|
81
|
+
* zoom: 10,
|
|
82
|
+
* path,
|
|
83
|
+
* },
|
|
84
|
+
* skipUrlEncoding: true,
|
|
85
|
+
* })
|
|
86
|
+
* .asNodeStream();
|
|
87
|
+
*
|
|
88
|
+
* // Handle the error.
|
|
89
|
+
* if (!response.body) {
|
|
90
|
+
* throw Error("No response body");
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* response.body.pipe(createWriteStream("pin.png"));
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @param pins - An array of {@link Pin} that specify the positions and label text of each pin.
|
|
97
|
+
* @param pinImage - Specify the image source for custom pin. Set this to "none" if you don't want to show a pin image.
|
|
98
|
+
* @param options - The style options of the pins. See {@link PinOptions}
|
|
99
|
+
* @returns - The composed query string.
|
|
100
|
+
*/
|
|
101
|
+
export declare function createPinsQuery(pinSets: PinSet[]): string;
|
|
102
|
+
//# sourceMappingURL=createPinsQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPinsQuery.d.ts","sourceRoot":"","sources":["../../src/createPinsQuery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;SAKK;IACL,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,mDAAmD;IACnD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAiBD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,QAAQ,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;IACvC,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAkBzD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { createMultiCollection } from "./createMultiCollection";
|
|
3
|
+
import { createMultiCollection } from "./createMultiCollection.js";
|
|
4
4
|
const optionKeyMap = {
|
|
5
5
|
opacity: "al",
|
|
6
6
|
labelAnchor: "la",
|
|
@@ -18,31 +18,50 @@ function isOptionKeyMap(key) {
|
|
|
18
18
|
* Create a pin query string for _get map static image_
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
|
-
* ```ts
|
|
21
|
+
* ```ts snippet:ReadmeSampleCreatePinsQuery
|
|
22
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
23
|
+
* import MapsRender, { PinSet, createPinsQuery } from "@azure-rest/maps-render";
|
|
24
|
+
* import { createWriteStream } from "node:fs";
|
|
22
25
|
*
|
|
23
|
-
* const
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
26
|
+
* const credential = new DefaultAzureCredential();
|
|
27
|
+
* const client = MapsRender(credential, "<maps-account-client-id>");
|
|
28
|
+
*
|
|
29
|
+
* const pins: PinSet[] = [
|
|
30
|
+
* {
|
|
31
|
+
* pins: [
|
|
32
|
+
* { coordinate: [52.577, 13.35], label: "Label start" },
|
|
33
|
+
* { coordinate: [52.6, 13.2988], label: "Label end" },
|
|
34
|
+
* ],
|
|
35
|
+
* pinImage: "default",
|
|
36
|
+
* options: {
|
|
37
|
+
* scale: 0.9,
|
|
38
|
+
* pinColor: "FF0000",
|
|
39
|
+
* labelColor: "0000FF",
|
|
40
|
+
* labelSizeInPixels: 18,
|
|
41
|
+
* },
|
|
42
|
+
* },
|
|
43
|
+
* ];
|
|
44
|
+
*
|
|
45
|
+
* const path = createPinsQuery(pins);
|
|
46
|
+
*
|
|
47
|
+
* const response = await client
|
|
48
|
+
* .path("/map/static")
|
|
49
|
+
* .get({
|
|
50
|
+
* queryParameters: {
|
|
51
|
+
* bbox: [13.228, 52.4559, 13.5794, 52.62],
|
|
52
|
+
* zoom: 10,
|
|
53
|
+
* path,
|
|
54
|
+
* },
|
|
55
|
+
* skipUrlEncoding: true,
|
|
56
|
+
* })
|
|
57
|
+
* .asNodeStream();
|
|
58
|
+
*
|
|
59
|
+
* // Handle the error.
|
|
60
|
+
* if (!response.body) {
|
|
61
|
+
* throw Error("No response body");
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
|
+
* response.body.pipe(createWriteStream("pin.png"));
|
|
46
65
|
* ```
|
|
47
66
|
*
|
|
48
67
|
* @param pins - An array of {@link Pin} that specify the positions and label text of each pin.
|