TypeScript and Woosmap Map

TypeScript 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.

If you are already using or plan to use TypeScript then you’re going to love what we recently released for you.

The Woosmap Map team has published official typings for the Map JavaScript API to DefinitelyTyped.
The DefinitelyTyped project is an open source project that maintains type declaration files for many packages including Woosmap Map. The Woosmap Map JavaScript declaration files (see source files on GitHub) are published as @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.

To start using it, install the types with the following command (or through your package dependencies):

npm i -D @types/google.maps

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

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 report any issue with these types, please open a support ticket.

1 Like