diff --git a/samples/layer-transit/README.md b/samples/layer-transit/README.md new file mode 100644 index 00000000..40445d93 --- /dev/null +++ b/samples/layer-transit/README.md @@ -0,0 +1,41 @@ +# Google Maps JavaScript Sample + +## layer-transit + +Transit layer sample. + +## Setup + +### Before starting run: + +`npm i` + +### Run an example on a local web server + +`cd samples/layer-transit` +`npm start` + +### Build an individual example + +`cd samples/layer-transit` +`npm run build` + +From 'samples': + +`npm run build --workspace=layer-transit/` + +### Build all of the examples. + +From 'samples': + +`npm run build-all` + +### Run lint to check for problems + +`cd samples/layer-transit` +`npx eslint index.ts` + +## Feedback + +For feedback related to this sample, please open a new issue on +[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues). diff --git a/samples/layer-transit/index.html b/samples/layer-transit/index.html new file mode 100644 index 00000000..8130e375 --- /dev/null +++ b/samples/layer-transit/index.html @@ -0,0 +1,22 @@ + + + + + + Transit Layer + + + + + + + + + + + diff --git a/samples/layer-transit/index.ts b/samples/layer-transit/index.ts new file mode 100644 index 00000000..5be4359f --- /dev/null +++ b/samples/layer-transit/index.ts @@ -0,0 +1,20 @@ +/** + * @license + * Copyright 2026 Google LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +// [START maps_layer_transit] +async function initMap(): Promise { + await google.maps.importLibrary("maps"); + + const mapElement = document.querySelector('gmp-map') as google.maps.MapElement; + const innerMap = mapElement.innerMap; + + const transitLayer = new google.maps.TransitLayer(); + + transitLayer.setMap(innerMap); +} + +initMap(); +// [END maps_layer_transit] diff --git a/samples/layer-transit/package.json b/samples/layer-transit/package.json new file mode 100644 index 00000000..23ad7dbe --- /dev/null +++ b/samples/layer-transit/package.json @@ -0,0 +1,14 @@ +{ + "name": "@js-api-samples/layer-transit", + "version": "1.0.0", + "scripts": { + "build": "tsc && bash ../jsfiddle.sh layer-transit && bash ../app.sh layer-transit && bash ../docs.sh layer-transit && npm run build:vite --workspace=. && bash ../dist.sh layer-transit", + "test": "tsc && npm run build:vite --workspace=.", + "start": "tsc && vite build --base './' && vite", + "build:vite": "vite build --base './'", + "preview": "vite preview" + }, + "dependencies": { + + } +} diff --git a/samples/layer-transit/style.css b/samples/layer-transit/style.css new file mode 100644 index 00000000..abb639ff --- /dev/null +++ b/samples/layer-transit/style.css @@ -0,0 +1,18 @@ +/** + * @license + * Copyright 2026 Google LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +/* [START maps_layer_transit] */ + +/* + * Optional: Makes the sample page fill the window. + */ +html, +body { + height: 100%; + margin: 0; + padding: 0; +} + +/* [END maps_layer_transit] */ \ No newline at end of file diff --git a/samples/layer-transit/tsconfig.json b/samples/layer-transit/tsconfig.json new file mode 100644 index 00000000..5ba470c0 --- /dev/null +++ b/samples/layer-transit/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "." + }, + "include": [ + "./*.ts", + ] +}