diff --git a/samples/web-components-markers/README.md b/samples/web-components-markers/README.md new file mode 100644 index 00000000..0e0f9dbf --- /dev/null +++ b/samples/web-components-markers/README.md @@ -0,0 +1,41 @@ +# Google Maps JavaScript Sample + +## web-components-markers + +Add a marker to a Google map using web components. + +## Setup + +### Before starting run: + +`npm i` + +### Run an example on a local web server + +`cd samples/web-components-markers` +`npm start` + +### Build an individual example + +`cd samples/web-components-markers` +`npm run build` + +From 'samples': + +`npm run build --workspace=web-components-markers/` + +### Build all of the examples. + +From 'samples': + +`npm run build-all` + +### Run lint to check for problems + +`cd samples/web-components-markers` +`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/web-components-markers/index.html b/samples/web-components-markers/index.html new file mode 100644 index 00000000..26555b2a --- /dev/null +++ b/samples/web-components-markers/index.html @@ -0,0 +1,34 @@ + + + + + + Add a Map with Markers using HTML + + + + + + + + + + + + + + diff --git a/samples/web-components-markers/index.ts b/samples/web-components-markers/index.ts new file mode 100644 index 00000000..e34d7316 --- /dev/null +++ b/samples/web-components-markers/index.ts @@ -0,0 +1,15 @@ +/** + * @license + * Copyright 2025 Google LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ + +// [START maps_web_components_markers] +// This example adds a map with markers, using web components. +// [START maps_web_components_markers_initmap] +async function initMap() { + console.log('Maps JavaScript API loaded.'); +} +// [END maps_web_components_markers_initmap] +initMap(); +// [END maps_web_components_markers] diff --git a/samples/web-components-markers/package.json b/samples/web-components-markers/package.json new file mode 100644 index 00000000..ef46297c --- /dev/null +++ b/samples/web-components-markers/package.json @@ -0,0 +1,14 @@ +{ + "name": "@js-api-samples/web-components-markers", + "version": "1.0.0", + "scripts": { + "build": "tsc && bash ../jsfiddle.sh web-components-markers && bash ../app.sh web-components-markers && bash ../docs.sh web-components-markers && npm run build:vite --workspace=. && bash ../dist.sh web-components-markers", + "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/web-components-markers/style.css b/samples/web-components-markers/style.css new file mode 100644 index 00000000..1e068074 --- /dev/null +++ b/samples/web-components-markers/style.css @@ -0,0 +1,24 @@ +/** + * @license + * Copyright 2025 Google LLC. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0 + */ +/* [START maps_web_components_markers] */ +/* + * Always set the map height explicitly to define the size of the div element + * that contains the map. + */ +gmp-map { + height: 100%; +} + +/* + * Optional: Makes the sample page fill the window. + */ +html, +body { + height: 100%; + margin: 0; + padding: 0; +} +/* [END maps_web_components_markers] */ \ No newline at end of file diff --git a/samples/web-components-markers/tsconfig.json b/samples/web-components-markers/tsconfig.json new file mode 100644 index 00000000..366aabb0 --- /dev/null +++ b/samples/web-components-markers/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "esnext", + "target": "esnext", + "strict": true, + "noImplicitAny": false, + "lib": [ + "es2015", + "esnext", + "es6", + "dom", + "dom.iterable" + ], + "moduleResolution": "Node", + "jsx": "preserve" + } +}