Introducing Places UI Kit: A ready-to-use, low-cost component library that lets you bring the familiar Google Maps UI for Places to any map of your choice. Try it out, andshare your input to help shape the future of GMP!

TypeScript and Google Maps

TypeScript is a typed superset of JavaScriptthat compiles to plain JavaScript. The snippet below demonstrates simple usageof Google Maps using TypeScript.

letmap:google.maps.Map;constcenter:google.maps.LatLngLiteral={lat:30,lng:-110};functioninitMap():void{map=newgoogle.maps.Map(document.getElementById("map")asHTMLElement,{center,zoom:8});}

Getting Started

TheDefinitelyTyped project isan open source projects that maintains typedeclaration files for many packages including Google Maps. The Google Maps JavaScript declarationfiles (seesource files on GitHub) can be installed using NPM from the@types/google.maps package.

npmi-D@types/google.maps
Note: These types are automatically generated. To report an issue with these types,please open asupport ticket.

Alpha and Beta Features

Thetypes typically do not have the properties, functions, or classes found in alpha orbeta releases. In many of these cases, the object can be cast to the correcttype.

The following error is caused by themapId beta property forMapOptions.

error TS2345: Argument of type '{ center: google.maps.LatLng; zoom: number;mapId: string; }' is not assignable to parameter of type 'MapOptions'. Objectliteral may only specify known properties, and 'mapId' does not exist in type'MapOptions'.

The above error can be corrected with the cast below.

{center:{lat:30,lng:-110},zoom:8,mapId:'1234'}asgoogle.maps.MapOptions

Conflicting @types packages

Some libraries may use a package other than@types/google.maps,which may cause conflicts. Use theskipLibCheck compiler option to avoid issues with inconsistent types.

{"compilerOptions":{"skipLibCheck":true}}

Specifying typeRoots

Some frameworks such as Angular may require specifying thetypeRoots compiler option to include types installed from@types/google.maps and all other "@types" packages.

Note: By default all visible ”@types” packages are included in your compilation.Packages in node_modules/@types of any enclosing folder are considered visible.
{..."compilerOptions":{..."typeRoots":["node_modules/@types",],...}}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-18 UTC.