Skip to content

Instantly share code, notes, and snippets.

@kumaraksi
Last active February 24, 2019 06:37
Show Gist options
  • Save kumaraksi/7bc6ed23aa93cdcc0eecf3bccfc2d2c1 to your computer and use it in GitHub Desktop.
Save kumaraksi/7bc6ed23aa93cdcc0eecf3bccfc2d2c1 to your computer and use it in GitHub Desktop.
export class GMap extends HTMLElement{
constructor(){
super();
const template = this.getTemplate();
const shadow = this.attachShadow({mode: 'open'});
shadow.appendChild(template.content.cloneNode(true));
}
getTemplate(){
const template = document.createElement('template');
template.innerHTML = `
<style>
#map{
height:400px;
width: 400px;
}
</style>
<div id="map" style="height:400px;width:400px"></div>
`;
return template;
}
// triggered once the element is added to the DOM.
async connectedCallback(){
console.log('connected');
}
// triggered once the element is removed to the DOM.
disconnectedCallback(){
}
}
customElements.define('google-map', GMap);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment