This repository includes definition files for the Wayfinder Web Map 2.0 API. JsDoc annotations provide intellisense in compatible IDE's.
The package is available on NPM. Add it to your dev dependencies.
# npm
npm install --save-dev @acquireweb/wayfinder-web-map-types
# pnpm
pnpm add -D @acquireweb/wayfinder-web-map-types
To make the types available in your project, add the packaged to the types
field of compilerOptions
in tsconfig.json:
{
"compilerOptions": {
"types": ["@acquireweb/wayfinder-web-map-types"]
}
}
All types are exported under the 'WF' namespace. You can access them by prefixing a type with 'WF'.
const destination: WF.Destination =
window.wayfinder.database.destinations.asArray[0];
function getAmenityName(amenity: WF.Amenity): string {
const amenityTypes = window.wayfinder.database.amenityTypes.asMap;
const amenityType = amenityTypes[amenity.type];
// ^? const amenityType: AmenityType
return amenityType.name;
}