-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Adds example maps for web components (#1618)
* feat: Adds demos for web components. Change-Id: I5998fb2fea9dbe9250f1d824c46143633ba7db78 * Update index.ts * Update index.ts
- Loading branch information
Showing
12 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
@license | ||
Copyright 2019 Google LLC. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
{% extends '../../src/_includes/layout.njk'%} {% block html %} | ||
<gmp-map id="marker-click-event-example" center="43.4142989,-124.2301242" zoom="4" map-id="DEMO_MAP_ID"> | ||
<gmp-advanced-marker position="37.4220656,-122.0840897" title="Mountain View, CA"></gmp-advanced-marker> | ||
<gmp-advanced-marker position="47.648994,-122.3503845" title="Seattle, WA"></gmp-advanced-marker> | ||
</gmp-map> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @license | ||
* Copyright 2019 Google LLC. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
// [START maps_web_components_events] | ||
// This example adds a map using web components. | ||
function initMap(): void { | ||
console.log('Maps JavaScript API loaded.'); | ||
const advancedMarkers = document.querySelectorAll("#marker-click-event-example gmp-advanced-marker"); | ||
for (const advancedMarker of advancedMarkers) { | ||
|
||
customElements.whenDefined(advancedMarker.localName).then(async () => { | ||
advancedMarker.addEventListener('gmp-click', async () => { | ||
|
||
const infoWindow = new google.maps.InfoWindow({ | ||
//@ts-ignore | ||
content: advancedMarker.title, | ||
}); | ||
infoWindow.open({ | ||
//@ts-ignore | ||
anchor: advancedMarker | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
initMap: () => void; | ||
} | ||
} | ||
window.initMap = initMap; | ||
// [END maps_web_components_events] | ||
export { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @license | ||
* Copyright 2019 Google LLC. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
@use 'sass:meta'; // To enable @use via meta.load-css and keep comments in order | ||
|
||
/* [START maps_web_components_events] */ | ||
@include meta.load-css("../../shared/scss/default.scss"); | ||
|
||
gmp-map { | ||
height: 500px; | ||
} | ||
|
||
/* [END maps_web_components_events] */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"title": "Add a Map Web Component with Events", | ||
"callback": "initMap", | ||
"libraries": ["marker"], | ||
"version": "beta", | ||
"tag": "web_components_events", | ||
"name": "web-components-events", | ||
"pagination": { | ||
"data": "mode", | ||
"size": 1, | ||
"alias": "mode" | ||
}, | ||
"permalink": "samples/{{ page.fileSlug }}/{{mode}}/{% if mode == 'jsfiddle' %}demo{% else %}index{% endif %}.{{ page.outputFileExtension }}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
@license | ||
Copyright 2019 Google LLC. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
{% extends '../../src/_includes/layout.njk'%} {% block html %} | ||
<gmp-map center="37.4220656,-122.0840897" zoom="10" map-id="DEMO_MAP_ID"></gmp-map> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @license | ||
* Copyright 2019 Google LLC. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
// [START maps_web_components_map] | ||
// This example adds a map using web components. | ||
function initMap(): void { | ||
console.log('Maps JavaScript API loaded.'); | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
initMap: () => void; | ||
} | ||
} | ||
window.initMap = initMap; | ||
// [END maps_web_components_map] | ||
export { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @license | ||
* Copyright 2019 Google LLC. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
@use 'sass:meta'; // To enable @use via meta.load-css and keep comments in order | ||
|
||
/* [START maps_web_components_map] */ | ||
@include meta.load-css("../../shared/scss/default.scss"); | ||
|
||
gmp-map { | ||
height: 500px; | ||
} | ||
|
||
/* [END maps_web_components_map] */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"title": "Add a Map Web Component", | ||
"callback": "initMap", | ||
"libraries": [], | ||
"version": "beta", | ||
"tag": "web_components_map", | ||
"name": "web-components-map", | ||
"pagination": { | ||
"data": "mode", | ||
"size": 1, | ||
"alias": "mode" | ||
}, | ||
"permalink": "samples/{{ page.fileSlug }}/{{mode}}/{% if mode == 'jsfiddle' %}demo{% else %}index{% endif %}.{{ page.outputFileExtension }}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<!-- | ||
@license | ||
Copyright 2019 Google LLC. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
{% extends '../../src/_includes/layout.njk'%} {% block html %} | ||
<gmp-map center="43.4142989,-124.2301242" zoom="4" map-id="DEMO_MAP_ID"> | ||
<gmp-advanced-marker position="37.4220656,-122.0840897" title="Mountain View, CA"></gmp-advanced-marker> | ||
<gmp-advanced-marker position="47.648994,-122.3503845" title="Seattle, WA"></gmp-advanced-marker> | ||
</gmp-map> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @license | ||
* Copyright 2019 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. | ||
function initMap(): void { | ||
console.log('Maps JavaScript API loaded.'); | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
initMap: () => void; | ||
} | ||
} | ||
window.initMap = initMap; | ||
// [END maps_web_components_markers] | ||
export { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* @license | ||
* Copyright 2019 Google LLC. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
@use 'sass:meta'; // To enable @use via meta.load-css and keep comments in order | ||
|
||
/* [START maps_web_components_markers] */ | ||
@include meta.load-css("../../shared/scss/default.scss"); | ||
|
||
gmp-map { | ||
height: 500px; | ||
} | ||
|
||
/* [END maps_web_components_markers] */ |
14 changes: 14 additions & 0 deletions
14
samples/web-components-markers/web-components-markers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"title": "Add a Map with Markers using Web Components", | ||
"callback": "initMap", | ||
"libraries": ["marker"], | ||
"version": "beta", | ||
"tag": "web_components_markers", | ||
"name": "web-components-markers", | ||
"pagination": { | ||
"data": "mode", | ||
"size": 1, | ||
"alias": "mode" | ||
}, | ||
"permalink": "samples/{{ page.fileSlug }}/{{mode}}/{% if mode == 'jsfiddle' %}demo{% else %}index{% endif %}.{{ page.outputFileExtension }}" | ||
} |