0

I am trying to use polymerjs3.0 google-map component but i am getting template getter must return HTMLTemplateElement error, can someone please post the code snippet on how to use polymer google-map component.

import { PolymerElement, html } from '@polymer/polymer';
import '@em-polymer/google-apis/google-maps-api.js';
import '@em-polymer/google-map/google-map-marker.js';

class GoogleMap extends PolymerElement {
  static get template() {
    return html ` <google-map fit-to-markers api-key="My Map Key"> 
          <google-map-marker latitude="37.78" longitude="-122.4" draggable="true">
          </google-map-marker> 
    </google-map> `;
  }
}
window.customElements.define('googlemap-page', GoogleMap);

Thanks in advance.

Jai
  • 74,255
  • 12
  • 74
  • 103

1 Answers1

1

You need a return statement in the template getter method, which returns a html tagged template:

static get template() {
    return html`<div>This is my template!</div>`;
//--^^^^^^-^^^^----Check for these two have to be present there.      
}
Jai
  • 74,255
  • 12
  • 74
  • 103
  • Can you add your polymer class code to your post? That would be nice to answer. – Jai Nov 29 '18 at 14:32
  • import {PolymerElement, html} from '@polymer/polymer'; import '@em-polymer/google-apis/google-maps-api.js'; import '@em-polymer/google-map/google-map-marker.js'; class GoogleMap extends PolymerElement { static get template() { return html` `; } } window.customElements.define('googlemap-page', GoogleMap); – Nishant Dec 03 '18 at 05:45
  • Could you please help me on this? – Nishant Dec 03 '18 at 10:49