Skip to content

Commit

Permalink
fix: places api - add icon param
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoCaimar committed Oct 17, 2024
1 parent 2323340 commit 3c7a685
Show file tree
Hide file tree
Showing 22 changed files with 8,950 additions and 1,388 deletions.
6,169 changes: 4,934 additions & 1,235 deletions demos/node-places-api/categories.mock.json

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion demos/node-places-api/category.mock.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"fullLabel": [
"Arts and Entertainment"
],
"parents": []
"parents": [],
"icon": {
"url": "https://static.arcgis.com/icons/places/Default_Arts_and_Entertainment_15.cim"
}
}
64 changes: 47 additions & 17 deletions demos/node-places-api/extent.mock.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,71 @@
{
"results": [
{
"placeId": "6eb039fa6c292d431b370f8ff9182955",
"placeId": "188ab43b2bec75c6e4f6d5df10afc003",
"location": {
"x": -118.001636,
"y": 33.802438
"x": -118.008724,
"y": 33.816751
},
"categories": [
{
"categoryId": "13043",
"label": "Donut Shop"
"categoryId": "13002",
"label": "Bakery"
},
{
"categoryId": "13065",
"label": "Restaurant"
}
],
"name": "Maxs Baked Goods",
"icon": {
"url": "https://static.arcgis.com/icons/places/Bakery_15.cim"
}
},
{
"placeId": "2a6ddf5433a1c9a664b268adbdcf7559",
"location": {
"x": -118.010416,
"y": 33.825168
},
"categories": [
{
"categoryId": "13001",
"label": "Bagel Shop"
},
{
"categoryId": "13065",
"label": "Restaurant"
},
{
"categoryId": "13002",
"label": "Bakery"
}
],
"name": "Donut King and Water"
"name": "Donut Storr",
"icon": {
"url": "https://static.arcgis.com/icons/places/Bakery_15.cim"
}
},
{
"placeId": "06dc48eba7c1c3106db6a0f498eaf1c7",
"placeId": "c602ca8f1010f95618c231046dbef3f6",
"location": {
"x": -118.001186,
"y": 33.809568
"x": -118.001473,
"y": 33.831684
},
"categories": [
{
"categoryId": "13002",
"label": "Bakery"
},
{
"categoryId": "13303",
"label": "Mexican Restaurant"
"categoryId": "13065",
"label": "Restaurant"
}
],
"name": "Panaderia Cortez"
"name": "Tlaxcala Bakery",
"icon": {
"url": "https://static.arcgis.com/icons/places/Bakery_15.cim"
}
},
{
"placeId": "693a02b6f4c32acf6d1060a164865da4",
Expand All @@ -47,20 +74,23 @@
"y": 33.795145
},
"categories": [
{
"categoryId": "13043",
"label": "Donut Shop"
},
{
"categoryId": "13001",
"label": "Bagel Shop"
},
{
"categoryId": "13065",
"label": "Restaurant"
},
{
"categoryId": "13002",
"label": "Bakery"
}
],
"name": "Amy's Donuts"
"name": "Amy's Donuts",
"icon": {
"url": "https://static.arcgis.com/icons/places/Bakery_15.cim"
}
}
]
}
5 changes: 4 additions & 1 deletion demos/node-places-api/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiKeyManager } from "@esri/arcgis-rest-request";
import { getCategories } from "@esri/arcgis-rest-places";
import { getCategories, IconOptions } from "@esri/arcgis-rest-places";
import * as dotenv from "dotenv";
import fs from "fs";
import find from "unist-util-find";
Expand All @@ -15,6 +15,7 @@ const authentication = ApiKeyManager.fromKey(process.env.API_KEY);

const { categories } = await getCategories({
endpoint: "https://places-api.arcgis.com/arcgis/rest/services/places-service/v1/categories",
icon: IconOptions.PNG,
authentication
});

Expand All @@ -34,6 +35,7 @@ const tree = {
type: "category",
id: c.categoryId,
fullLabel: c.fullLabel || [],
icon: c.icon,
children: []
};
})
Expand All @@ -50,6 +52,7 @@ childCategories.reduce((tree, child) => {
type: "category",
id: child.categoryId,
fullLabel: child.fullLabel || [],
icon: child.icon,
children: []
});
return tree;
Expand Down
12 changes: 10 additions & 2 deletions demos/node-places-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
findPlacesWithinExtent,
getPlaceDetails,
getCategories,
getCategory
getCategory,
IconOptions
} from "@esri/arcgis-rest-places";
import * as dotenv from "dotenv";
import fs from "fs";
Expand All @@ -17,6 +18,7 @@ let lastResponse = await findPlacesNearPoint({
x: -3.1883,
y: 55.9533,
radius: 100,
icon: IconOptions.PNG,
authentication
});

Expand All @@ -40,6 +42,7 @@ const extentResults = await findPlacesWithinExtent({
xmax: -117.995753,
ymax: 33.833337,
categoryIds: ["13002"],
icon: IconOptions.CIM,
authentication
});

Expand All @@ -51,6 +54,7 @@ fs.promises.writeFile(
const placeResult = await getPlaceDetails({
placeId: extentResults.results[0].placeId,
requestedFields: ["all"],
icon: IconOptions.SVG,
authentication
});

Expand Down Expand Up @@ -83,7 +87,10 @@ if (placeResult.placeDetails.categories) {
);
}

const { categories } = await getCategories({ authentication });
const { categories } = await getCategories({
authentication,
icon: IconOptions.PNG
});

console.log("Found categories: ", categories.length);

Expand All @@ -93,6 +100,7 @@ fs.promises.writeFile(
);
const categoryMock = await getCategory({
categoryId: "10000",
icon: IconOptions.CIM,
authentication
});

Expand Down
Loading

0 comments on commit 3c7a685

Please sign in to comment.