Source: https://developers.woosmap.com/products/map-api/concepts/using-typescript/

> For clean Markdown of any page, append `.md` to the page URL.

> For a complete documentation index, see https://developers.woosmap.com/llms.txt

# Using Typescript



## Overview
[TypeScript](https://www.typescriptlang.org/) is a strongly typed programming language that compiles to plain
JavaScript. Typing your code allows to catch errors early in your editor and makes it incomparably easier to understand
and maintain.

The Woosmap Map JS API has dedicated Typescript typings published on [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped/).
The [DefinitelyTyped project](https://github.com/DefinitelyTyped/DefinitelyTyped) is an open source project that
maintains type [declaration files](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html) for
many packages including Woosmap Map. The Woosmap Map JavaScript declaration files (
see [source files](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/woosmap.map) on GitHub) are
published as [@types/woosmap.map](https://www.npmjs.com/package/@types/woosmap.map) package on NPM.

These TypeScript definitions are generated directly from the API source code, bringing you the most accurate up-to-date
TypeScript definitions for the Map JS API to use in your web apps.

## Getting Started

To start using it, install the types with the following command:

```shell
npm i -D @types/woosmap.map
```

Or through your package dependencies:

```json
"devDependencies": {
  "@types/woosmap.map": "~1.4.1",
}
```

And here is a basic example on how to create a Map:

```typescript
let map: woosmap.map.Map;
const initialCenter: woosmap.map.LatLngLiteral = {lat: 42.3, lng: 2.4};
const initialZoom: number = 7;

function initMap(): void {
    map = new woosmap.map.Map(document.getElementById("map") as HTMLElement, {
        initialCenter,
        initialZoom
    });
}
```

To help you build your locator using Typescript and Map JS API, feel free to look at
this [sample application](https://github.com/Woosmap/ts-mapjs-storelocator-sample/) on GitHub.
