File tree Expand file tree Collapse file tree 6 files changed +145
-0
lines changed
samples/web-components-markers Expand file tree Collapse file tree 6 files changed +145
-0
lines changed Original file line number Diff line number Diff line change 1+ # Google Maps JavaScript Sample
2+
3+ ## web-components-markers
4+
5+ Add a marker to a Google map using web components.
6+
7+ ## Setup
8+
9+ ### Before starting run:
10+
11+ ` npm i `
12+
13+ ### Run an example on a local web server
14+
15+ ` cd samples/web-components-markers `
16+ ` npm start `
17+
18+ ### Build an individual example
19+
20+ ` cd samples/web-components-markers `
21+ ` npm run build `
22+
23+ From 'samples':
24+
25+ ` npm run build --workspace=web-components-markers/ `
26+
27+ ### Build all of the examples.
28+
29+ From 'samples':
30+
31+ ` npm run build-all `
32+
33+ ### Run lint to check for problems
34+
35+ ` cd samples/web-components-markers `
36+ ` npx eslint index.ts `
37+
38+ ## Feedback
39+
40+ For feedback related to this sample, please open a new issue on
41+ [ GitHub] ( https://github.com/googlemaps-samples/js-api-samples/issues ) .
Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ <!--
3+ @license
4+ Copyright 2025 Google LLC. All Rights Reserved.
5+ SPDX-License-Identifier: Apache-2.0
6+ -->
7+ <!-- [START maps_web_components_markers] -->
8+ < html >
9+ < head >
10+ < title > Add a Map with Markers using HTML</ title >
11+
12+ < link rel ="stylesheet " type ="text/css " href ="./style.css " />
13+ < script type ="module " src ="./index.js "> </ script >
14+ < script
15+ src ="https://maps.googleapis.com/maps/api/js?key=AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8&libraries=maps,marker&v=weekly "
16+ defer
17+ > </ script >
18+ </ head >
19+ < body >
20+ <!-- [START maps_web_components_markers_div] -->
21+ < gmp-map
22+ center ="41.027748173921374, -92.41852445367961 "
23+ zoom ="13 "
24+ map-id ="DEMO_MAP_ID "
25+ >
26+ < gmp-advanced-marker
27+ position ="41.027748173921374, -92.41852445367961 "
28+ title ="Ottumwa, IA "
29+ > </ gmp-advanced-marker >
30+ </ gmp-map >
31+ <!-- [END maps_web_components_markers_div] -->
32+ </ body >
33+ </ html >
34+ <!-- [END maps_web_components_markers] -->
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright 2025 Google LLC. All Rights Reserved.
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ // [START maps_web_components_markers]
8+ // This example adds a map with markers, using web components.
9+ // [START maps_web_components_markers_initmap]
10+ async function initMap ( ) {
11+ console . log ( 'Maps JavaScript API loaded.' ) ;
12+ }
13+ // [END maps_web_components_markers_initmap]
14+ initMap ( ) ;
15+ // [END maps_web_components_markers]
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @js-api-samples/web-components-markers" ,
3+ "version" : " 1.0.0" ,
4+ "scripts" : {
5+ "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" ,
6+ "test" : " tsc && npm run build:vite --workspace=." ,
7+ "start" : " tsc && vite build --base './' && vite" ,
8+ "build:vite" : " vite build --base './'" ,
9+ "preview" : " vite preview"
10+ },
11+ "dependencies" : {
12+
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ /**
2+ * @license
3+ * Copyright 2025 Google LLC. All Rights Reserved.
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+ /* [START maps_web_components_markers] */
7+ /*
8+ * Always set the map height explicitly to define the size of the div element
9+ * that contains the map.
10+ */
11+ gmp-map {
12+ height : 100% ;
13+ }
14+
15+ /*
16+ * Optional: Makes the sample page fill the window.
17+ */
18+ html ,
19+ body {
20+ height : 100% ;
21+ margin : 0 ;
22+ padding : 0 ;
23+ }
24+ /* [END maps_web_components_markers] */
Original file line number Diff line number Diff line change 1+ {
2+ "compilerOptions" : {
3+ "module" : " esnext" ,
4+ "target" : " esnext" ,
5+ "strict" : true ,
6+ "noImplicitAny" : false ,
7+ "lib" : [
8+ " es2015" ,
9+ " esnext" ,
10+ " es6" ,
11+ " dom" ,
12+ " dom.iterable"
13+ ],
14+ "moduleResolution" : " Node" ,
15+ "jsx" : " preserve"
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments