Google Maps Platform JavaScript API and TypeScript

In July, we started rolling out TypeScript samples in the Maps JavaScript API documentation to better support modern web developers. According to a 2019 JavaScript developer survey, nearly 60% have used TypeScript and will use it again, while over 20% are interested in learning it. TypeScript is growing in popularity and we hope to make the experience the best it can be for Google Maps Platform developers. We think it’s important to support TypeScript not only because it’s popular, but because it allows developers to validate that their code is correct and provide better experiences with Google Maps Platform.

You can find the new sample code by clicking the TypeScript tab on any snippet. For example, here’s our Simple Map sample for JavaScript:

JavaScript SnippetCode snippets with JavaScript tab

And here it is with added TypeScript support:

TypeScript SnippetCode snippets now have a TypeScript tab

To help you get started, we also published a TypeScript and Google Maps Platform guide that covers many of the basics including possible compiler options and installation instructions for typings. We want to call out that this wouldn’t have been possible without the work of the open source TypeScript community and the type definitions they maintain and publish on Definitely Typed. These types can be installed via NPM by running the following:

  npm i -D @types/googlemaps

Node.js developers using Google Maps Platform APIs from server environments should not feel left out–a TypeScript rewrite of the client library was published earlier this year.

For more information on Google Maps Platform, visit our website.

The Original Article can be found on google.com

#javascript #typescript #api #google-maps #developer

Google Maps Platform JavaScript API and TypeScript
4.70 GEEK