【问题标题】:Polymer 3 - Google Maps files missingPolymer 3 - 谷歌地图文件丢失
【发布时间】:2018-11-11 03:50:13
【问题描述】:

我遇到了与Polymer 3 - Google Maps 相同的问题。看完上面的帖子,我好像漏掉了google-apis/google-maps-api.jsgoogle-map-marker.js这两个文件。

希望它能下载谷歌地图的所有依赖文件,我发出了这些命令:

npm install @em-polymer/google-map
npm install google-maps
npm install

我做错了什么?

【问题讨论】:

  • 重新格式化问题以使其更易于阅读。

标签: google-maps polymer-3.x


【解决方案1】:

这对我有用。

import { html } from '@polymer/lit-element';
    import '@em-polymer/google-map/google-map.js';
    import '@em-polymer/google-map/google-map-marker.js';
    import { PageViewElement } from './page-view-element.js';

    // These are the shared styles needed by this element.
    import { SharedStyles } from './shared-styles.js';

    class MyView1 extends PageViewElement {
      render() {
        return html`
          ${SharedStyles}

          <section>
            <h2>Static page</h2>
            <p>This is a text-only page.</p>
            <p>It doesn't do anything other than display some static text.</p>
          </section>
          <section>
            <style>
            google-map {
              height: 600px;
            }
          </style>
          <google-map latitude="39.84143133531688" longitude="-117.4895451470561" api-key="1234"></google-map>
            </section>
        `;
      }
    }

    window.customElements.define('my-view1', MyView1);

【讨论】:

  • 这里的PageViewElement 是什么?我正在使用 polymerElement.. 不是 litElement
猜你喜欢
  • 2021-02-15
  • 1970-01-01
  • 2012-12-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-11
  • 1970-01-01
相关资源
最近更新 更多